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

Unreliable Messaging connection

Hi,

 

I'm working on a small app that just fetches some JSON on the companion side, and then forwards it to the watch for displaying. It's almost identical to the Weather Example posted of the Messaging Guide.

 

However, I can only get it to work about 20% of the time. I have the developer bridge enabled on both my phone and the watch. A lot of the times the "onopen" callback is never called, and even if it is there's a high chance that no data will make it through. 

 

I did notice the companion app is often marked as "Inactive". If I just keep on redeploying it again and again it will work eventually, usually in about 20% of the cases. Therefore I don't think there's an issue in my code (it's as trivial as the weather example, and looks identical), and it does work, if the API manages to make the connection and send the data through. 

 

On the other hand, the built-in weather app provided by Fitbit seems to work fine at all times, although I'm not sure if it is built on the same SDK that we use (maybe the fitbit OS devs can develop "native" apps?).

 

Are there others experiencing similar issues? Any ideas on how to address this?

Best Answer
13 REPLIES 13

Would you be willing to post an example project on Github so we can take a look? Can you also let me know iOS/Android versions etc. Thanks

 

For your reference, the weather app uses the File Transfer API to periodically send the data.

 

 

Best Answer

I am having the same issues. I have to remove the app completely from the watch and then redeploy in order to get it to work. Even then, there are issues with the peer connection working consistently and the data being passed from the companion to the app.

 

I am working with Android

Best Answer

Always been the case with me as well. I just keep installing it until it works.  Seems the Settings page will be inactive until the watch app/clockface has fully finished executing.

Best Answer

I have timed it and there is 1929 millisecond between when the companion starts and when the peer connection opens. This means that I cannot pass error messages to the device.

Is there any word on when this will be looked at?

Best Answer

I am having similar issues as well.  

 

It seems like the sync between the Fitbit app (iOS) and the Ionic triggers the companion app and subsequent data transfer but is there any alternative?

 

I am using the weather example as well and it appears the 'refresh interval' is somewhat useless?  I would post to Git but it seriously is just like the weather example on the Fitbit dev site.

 

At a high level, how is the watch-to-companion interaction supposed to occur?

Best Answer
0 Votes

I have similar problem, the messaging.peerSocket.onopen will never fire up when the program is just uploaded to ionic watch.  This can be temporarily solved by exit the program and run it again manually.

Best Answer

I have the Weather function in my clockface start 5 sec after the clockface starts and it retries every 5 seconds until it gets the weather.

Best Answer
0 Votes

Does that work consistently for you? 

Best Answer
0 Votes

Do you have any news about this bug? I just use the messaging module to communicate the companion with the app and the connection is established very rarely ...

Best Answer
0 Votes

@pachesnel wrote:

Do you have any news about this bug? I just use the messaging module to communicate the companion with the app and the connection is established very rarely ...


Can you provide some information about your setup? Are you Android/iOS/Windows. Have you applied the latest mobile app updates and latest device firmware?

Best Answer
0 Votes

I worked all morning on my little application and the connection between the companion and the app worked without problems.Then suddenly nothing worked and I have this message error : Connection error: 2 - unknown(Optional(8))

 

I Try : 

  1. Delete app + reinstall 
  2. Stop reload Fitbit studio 
  3. Empty the cache on the web page
  4. Restart the Iphone
  5. Restart the watch

however, it works very well with the simulator

 

  • My iPhone 6 as the last version 11.3 of the OS 
  • My Ionic as the last version : 32.4.1
Best Answer
0 Votes

Ok, I try to find why the peerSocket on companion stop working and apparently the problem become from the size of the message I try to send between companion and app. at first I used a JSON format of this type without any problem with the simulator and the ionic watch. 

 

{"statePrinter":"Printing","printName":"Kossel Mini","filePrintName":"KM_jonction_1","percent":0,"temperature":20.33,"temperatureTarget":0,"temperatureBed":54.81,"temperatureBedTarget":60,"printTimeLeft":"30"}

 After a few hours of coding, I could not use peerSocket.send () on the companion side with the ionic but everything worked on the simulator.

I tried later to send a shorter message and it worked! So I changed my json for a simple array :

 

["Printing",Kossel Mini,"KM_jonction_2",3,220.02,220,60.24,60]

I'm happy to have found the problem, however I had typed this:

 

 

// Listen for the onerror event
peerSocket.onerror = function(err) {
  // Handle any errors
  console.log("Connection error: " + err.code + " - " + err.message);
}

and my error message returned is not very explicit ...

 

 

 

Connection error: 2 - unknown(Optional(8))

 

 

 

 

 

Best Answer
0 Votes

I spoke a little fast. The message is back, What is strange is that my buffer returns to me a value of 50, which seems to me below the limit. I now go through a file where I store the information, it works for now but I would still like to understand my concerns with peerSocket.send () buffer limit. 

Best Answer
0 Votes