question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unity .net / nodejs problem

See original GitHub issue

Hello! I would like to ask for help. What could be the problem?

Unity Client

using UnityEngine;
using SocketIOClient;

public class NetworkClient : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        var client = new SocketIO("http://localhost:3000/");
        client.On("connection", socket => {
            Debug.Log("test");
        });
    }
    // Update is called once per frame
    void Update()
    {


    }
}

NodeJS server


const io = new Server();

io.on("connection", (socket) => {
  console.log("test 2")
});

io.listen(3000);

I start both and for some reason there is no communication. What am I wrong about? Thank you in advance for your answer. Have a nice day!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
doghappycommented, Dec 12, 2021

Is there a line of code missing?

    void Start()
    {
        var client = new SocketIO("http://localhost:3000/");
        client.On("connection", socket => {
            Debug.Log("test");
        });
        await client.ConnectAsync();
        // ^^^^^^^^^^^^^^^
    }
0reactions
jurniorescommented, Apr 6, 2022

I created Unity Sample https://github.com/devprog-dev/UnitySocketIOPlugins

don’t click link, just copy and paste on web browser

check it. referenced it here.

Your plugins folder is all in Meta

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lost in socketing: Unity with node.js?
Hi guys I'm quite new to socketing and all the asynchronous client-server stuff. I'm making web game that uses webplayer to display battle ......
Read more >
Node.js - Unity, Socket gets disconnected after getting re- ...
I'm developing a Node.js - Unity game where I'm using sockets, for users to get connect to the game. I getting an issue,...
Read more >
Node.js vs .NET: What to Choose in 2023
Both are powerful tools for building web applications, but they have distinct differences that can impact your project's success.
Read more >
Socket.io in Unity3D | Sololearn: Learn to code for FREE!
I am working on a Unity game that uses a Socket.io server, running in Node.js. The problem is that I could not found...
Read more >
Would Node.js work well with connecting unity clients?
Hello, I'm currently trying to develop a mmo ish game, my game will have worlds that are created by players, these worlds will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found