i am working with websocket to create a live collab editor and it is working in the same browser but it is not working in different browsers.
And i am also getting a error saying websocket connection to “wss://y-webrtc-signaling-us.herokuapp.com/” failed.
how to solve the problem?
You might be confusing websockets and webrtc. Are you sure y-webrtc-signaling-us.herokuapp.com is a websocket?
WebRTC requires a signaling server, because peers cannot usually connect directly over the open internet–they require an intermediary that is publicly available with an open IP address, so that “ICE” (interactive connectivity establishment) can occur (see ICE • BlogGeek.me)
Websockets, on the other hand, (and websockets for yjs in particular) require a dedicated server whose software speaks the yjs y-protocol. The y-websocket sample server does this job, as does the @hocuspocus/server.
Are you running one of those servers on your heroku endpoint?
Can you please help me in how to host my own websocket server online publicly so that i can use it cross platform?
I was thinking the same thing because I haven’t used y-webrtc before, but it looks like the signaling server is a websocket.
y-webrtc:
Signaling:
I can’t say whether y-webrtc-signaling-us.herokuapp.com
is working or even maintained any longer.
As @canadaduane mentioned though, y-websocket
and y-webrtc
are very different things. It’s not clear from your question which one you are using.
i am currently using websocket server and the one i have used is not active anymore. kindly help me how to host my own websocket server online publicly so that i can use it cross platform?
Before you host a public websocket server, can you confirm that your YJS app works with a websocket server hosted on your local machine?
e.g.
HOST=localhost PORT=1234 npx y-websocket
The process for a public websocket server will be very similar, you just need a host that opens the correct port. Every hosting platform is different.
Yes it working locally but i need to host it publicly to use it in different devices how can i do that ?
Okay, that’s good.
To host it publicly you need a hosting platform that supports NodeJS and websockets. I currently use DigitalOcean’s App Platform, and I believe it is possible on Heroku but there are other NodeJS hosting services you can use. Just confirm that they support websockets.
Getting the right HOST and PORT can sometimes be annoying on these platforms. For example, on DigitalOcean I set HOST to myapp-hmim8.ondigitalocean.app/
and PORT to 80
as that is the only port that they expose publicly.
Aside: A one-click y-websocket deploy would be nice for onboarding.