Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error connecting to websocket

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. 

Best Answer
0 Votes
4 REPLIES 4

I used the same URL, except without the trailing /

 

That shouldn't matter, but try it anyway.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Unfortunately getting rid of the trailing / didn't fix the error

Best Answer
0 Votes

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.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Are you able to try it with wss?

wss://127.0.0.1:8080

Best Answer