02-21-2019 13:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-21-2019 13:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
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?
Answered! Go to the Best Answer.
Accepted Solutions
02-21-2019 19:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-21-2019 19:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.
Gondwana Software

02-21-2019 19:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-21-2019 19:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.
Gondwana Software

02-22-2019 03:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-22-2019 03:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thanks for the reply. I will switch to files on the next update.

02-19-2022 18:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-19-2022 18:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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!

02-19-2022 18:06
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-19-2022 18:06
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
It would be interesting to see whether uninstalling and reinstalling your app brought it back to life.
Gondwana Software

02-21-2022 11:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-21-2022 11:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.

02-21-2022 11:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-21-2022 11:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.
Gondwana Software

02-21-2022 12:00
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-21-2022 12:00
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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

