- Home /
How do I connect to a server in LAN from a different computer? I'm using socket.io and nodejs
The connection is working locally just fine. But I need to connect to different machine (which runs node js server) which act as client. I'm using socket.io to transfer data.
The server is running on the local host in server PC. This is the URL which I'm using in client to connect locally.
ws://127.0.0.1:52300/socket.io/?EIO=4&transport=websocket
This is the server side code related to the port var io = require('socket.io')(process.env.PORT||52300)
I have tried connecting server and client using this URL, but there was no luck. ws://192.168.43.44:52300/socket.io/?EIO=4&transport=websocket (192.168.43.44 is server IP address)
I cannot seem to connect from a different machine which shares the same LAN. Can any one help? I'm really stuck here.
Answer by CmdrZin · Oct 13, 2020 at 03:04 AM
I have been working to update github.com/AlexanderDykov/Unity-NodeJS-Game project and had no problem having a remote laptop running a Client with the Url changed to the Host's IP.
I replaced the 127.0.0.1 with 192.168.0.2 (my Host's IP) and it ran fine over WiFi to the LAN the Host is on. No changes were needed to the server.js file.
I'd double check how the Client Url is established. In this project it is hardcoded in the Network script, but overwritten in the Editor.
My project is at https://github.com/CmdrZin/NodeJS
Your answer
Follow this Question
Related Questions
UNET - Password protection approach. 2 Answers
Unity Client & Server Socket 1 Answer
Dedicated server lobby problem 0 Answers
Need Help in Sending JSONOBJECT to Node Js 1 Answer
Unity vs client-side prediction 0 Answers