09-02-2017 07:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-02-2017 07:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The messaging docs seem to suggest guarding `send`s on checking the `readyState` of the `peerSocket`.
This leads me to two lines of questioning:
1. When would the messaging socket be closed? Maybe more generally, what's the execution lifecycle of the device app and the companion app and how does that relate to the socket lifecycle?
2. What is the error behavior when a `send` is attempted, but the socket isn't `OPEN`? It seems like the BART example doesn't guard its `send`s and might be usually okay?
Thanks!
Answered! Go to the Best Answer.

Accepted Solutions
09-03-2017 10:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


09-03-2017 10:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
1. The messaging socket would be closed if the Fitbit mobile application was not running, or bluetooth was disconnected.
2. You'd get an error in the console log, and the `onerror` event should be emitted.
09-03-2017 10:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


09-03-2017 10:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
1. The messaging socket would be closed if the Fitbit mobile application was not running, or bluetooth was disconnected.
2. You'd get an error in the console log, and the `onerror` event should be emitted.
08-02-2021 16:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-02-2021 16:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I tried using the "close" event listener on messaging api and even though the companion has unloaded, which means that the socket's would be closed, the "close" event listener does not trigger whatsoever.
Using SDK: 4.3.0

