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.
Unfortunately getting rid of the trailing / didn't fix the error
Best AnswerForgive 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.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Are you able to try it with wss?
wss://127.0.0.1:8080