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

messaging socket randomly not open

ANSWERED

Is there some documentation I'm missing or something. I used the example code for settings using a companion and messaging. I've noticed over the last few months that users complain of settings not working correctly. I've also noticed when running my clock face from the Fitbit studio, on my physical phone and my physical watch, that randomly the peer socket has no connection. I can add/remove one line of code (just a console.log), re-run the clock face, and after a new side-load, the socket is connected fine. I randomly don't have a socket connection when I install/run/side-load the clock-face and I can demonstrably show that it is agnostic of my code. Do others have this issue? I know that some users of my clock face have no problems with settings. Every published review of my clock face through many versions haven't seen an issue with settings. The last reviewer did. I've spent half of the day trying to replicate conditions where settings don't save correctly and I've narrowed it down to the messaging API and whether a socket exists. Why would the socket not be reopened? Is there a way for us to force a retry on the socket connection?

Best Answer
1 BEST ANSWER

Accepted Solutions

Messaging is indeed flakey. The Fitbit app is subject to the whims of the host operating system, which can suspend or kill processes at its leisure. This makes the process seem rather random.

 

There are a couple of things you can do to try to make messaging more reliable: set the companion app to run in background, and send a message from watch to companion every so often (just to wake it up). You'll still have to keep an eye on the state of the sockets and cope with problems.

 

You can also transfer settings using files, which is a bit more reliable than messaging.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
0 Votes
7 REPLIES 7

Messaging is indeed flakey. The Fitbit app is subject to the whims of the host operating system, which can suspend or kill processes at its leisure. This makes the process seem rather random.

 

There are a couple of things you can do to try to make messaging more reliable: set the companion app to run in background, and send a message from watch to companion every so often (just to wake it up). You'll still have to keep an eye on the state of the sockets and cope with problems.

 

You can also transfer settings using files, which is a bit more reliable than messaging.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Thanks for the reply. I will switch to files on the next update.

Best Answer
0 Votes

I'm currently having a similar issue. I had an app which was able to use companion API and messaging API. However today, I was updating some features and I noticed that the messages are not going through when two days ago, it worked fine. I checked the peerSocket.readyState and peerSocket.OPEN values and I found the latter to always get 0. Is this still related to the Host OS issue that you mentioned?

Ty in advance! 

Best Answer
0 Votes

It would be interesting to see whether uninstalling and reinstalling your app brought it back to life.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

It seems like it did. I removed the app then restarted my phone. I re-installed the app and messages are going through now. I may have to start using file transfer too in the future.

Best Answer
0 Votes

That's a shame in some ways. It's as though the Fitbit mobile app ceases passing messages for an app in some circumstances, and won't start doing so again.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

It is and the bad part of it is that there is no clear reason why that is obvious to the developer. Also there is no way for you to know if the messages are going through unless you keep a control over it. However if the app needs to send info , like in my case, it will be useless 

Best Answer
0 Votes