2

I'm trying to host a Websocket server on my heroku app. There already is a GraphQL server running, but I don't think it's the cause of my problem.
So my server is started like this

const wss = new ws.Server({ port: port }, () => console.log(`Serveur WebSocket prêt ${port}`));

There is no error, but when I try to connect to the server in my browser, just like this :

const ws = new WebSocket('wss://ethyme-api.herokuapp.com/');

I get an error 404.
So my question is, what is the path of the ws server, so I can connect to it ?
Thanks

Jacques
  • 140
  • 1
  • 10

1 Answers1

1

If your Heroku app is called ethyme-api and and your locally run application is available under ws://localhost:$PORT/ the websocket will be available under wss://ethyme-api.herokuapp.com/ and ws://ethyme-api.herokuapp.com/

Tin Nguyen
  • 5,250
  • 1
  • 12
  • 32
  • no, here is what happens when i connect to these urls : `WebSocket connection to 'wss://ethyme-api.herokuapp.com/' failed: Error during WebSocket handshake: Unexpected response code: 404` – Jacques Feb 19 '20 at 15:47
  • When running the websocket server locally. How do you connect to it? Is it `ws://localhost:$PORT/`? Is it `ws://localhost:$PORT/somemoretext`? If it contains `somemoretext` you need to include them for the Heroku URL as well. – Tin Nguyen Feb 19 '20 at 15:58
  • It's just `ws://localhost:8000` – Jacques Feb 19 '20 at 16:02