05-19-2021 16:05
05-19-2021 16:05
I have an app that sends messages to a companion which is then supposed to communicate with a simple websocket that I have created.
I have created a websocket server that runs on ws://127.0.0.1:8080/ , but when attempting to connect to that websocket using my companion, I receive the following error: "WebSocket connection to 'ws://127.0.0.1:8080/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED".
The code I am using in my companion app is simply the code given in https://dev.fitbit.com/build/reference/companion-api/websocket/ but with wsUri='ws://127.0.0.1:8080/'.
Any pointers to why I am getting this error? Am I actually implementing websockets correctly? Please help.
05-19-2021 16:19
05-19-2021 16:19
I used the same URL, except without the trailing /
That shouldn't matter, but try it anyway.
05-19-2021 16:27
05-19-2021 16:27
Unfortunately getting rid of the trailing / didn't fix the error
05-20-2021 21:54
05-20-2021 21:54
Forgive me for asking this, but is the ws server running on the same device as the Fitbit companion (which probably means your phone)?
Other things to try would be to see if your companion can connect to other ws servers (eg, internet-hosted), and whether your ws server can be connected to from other ws clients (ie, not your companion). This would isolate the problem to companion or server.
05-25-2021 05:51
05-25-2021 05:51
Are you able to try it with wss?
wss://127.0.0.1:8080