Errors with Websockets, Express.js, and replit

I am making a game where I have a websocket that works on my local pc. However, in replit, it isn’t registering the client.

https://replit.com/@LucienDuchateau/Texas-Holdem-Ws-1#server/index.html


In the top image the website is opened. In the bottom image its lacking the "New client connected with ID: "… part on line 14 of index.html and none of the buttons are sending messages to the websocket.

Thanks!

Hey I found that you can connect if you type in the url like this:

Before:
WebSocket('ws:localhost:3000/echo');

After:
WebSocket('wss://Texas-Holdem-Ws-1.LucienDuchateau.repl.co/echo');

Example here https://Texas-Holdem-Ws-1.sharkcoding.repl.co

2 Likes

Thanks! I didn’t realize I could just do that, I though it got done on the backend by Replit. Thanks!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.