When I run it locally it works, but I want other devices in the same network to access the websocket. When I use my IP address instead of localhost, it doesn’t connect. So, it’s currently only working on the device running the websocket server, but not any other local devices.
Am I approaching this wrong? How would I fix this?
Hi ! I am still having trouble implementing y-websocket with JS.
const provider = new WebsocketProvider('ws://192.168.xxx.xxx:1234', 'rectangle-demo', ydoc);
I tried changing “ws://localhost:1234” to “ws://192.168.xxx.xxx:1234” and it still doesn’t work.
I tried setting the HOST=0.0.0.0 as you recommend using $env:HOST=0.0.0.0
And I am running the websocket using the command: npx y-websocket-server --host 0.0.0.0 --port 1234
gives the result running at 'localhost' on port 1234
Shouldn’t the “localhost” change to the ip address?
In the console this pops : WebSocket connection to 'ws://192.168.xxx.xxx:1234/rectangle-demo' failed:
It just works on the localhost
netstat -an | findstr 1234
TCP [::1]:1234 [::]:0 LISTENING
TCP [::1]:1234 [::1]:56984 ESTABLISHED
TCP [::1]:56984 [::1]:1234 ESTABLISHED
And the port is just listening to ipv6 but not on ipv4. So I guess --host is not helping here.
What mistake am I making? And how to fix this? @dmonad@canadaduane
As I said, check your firewall and maybe try out if other applications work. I’m not a network expert and I don’t understand your setup (my router is also preventing direct communication between devices).
y-websocket simply uses the http module of nodejs. If you can get to work, you can get y-websocket to work.