The docs are missing examples on using the websockets api on the companion. Is it possible to have a websocket between the companion and an external server?
I want to do something similar to the Leaderboard app where you can cheer/taunt a friend. I was thinking of doing this with websockets, but if there is another way, please let me know 🙂
Thanks!
Answered! Go to the Best Answer.
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
You can use WebSockets as long as you've requested the access_internet permission and you're connecting to a secure server (ie wss://).
You can see docs here: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
For your describe use case, it sounds like fetch would be sufficient though. WebSockets are useful if you want the server to be able to push data to the companion, but if you're just pushing actions regular HTTP requests should be sufficient.
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
You can use WebSockets as long as you've requested the access_internet permission and you're connecting to a secure server (ie wss://).
You can see docs here: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
For your describe use case, it sounds like fetch would be sufficient though. WebSockets are useful if you want the server to be able to push data to the companion, but if you're just pushing actions regular HTTP requests should be sufficient.
The original poster asked about websockets, not about Fetch.
Redirecting the question leaves users who are looking for websocket information and examples driving down a dead end road.
I made ws server and client to connect my fitbit versa and externel system (3rd party system)
But It appears that I have to use wss protocol
What is defference with ws and wss protocol?
Do you have any wss server example???
I really hard to make wss server
Please give me answer as soon as possible
My email address is abraham728@hanmail.net
If you need my code I can show you my code.
But my code is just websocket server's basic example
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
wss:// is the secure version of ws://, it requires a valid certificate for the hostname you're using.
Best Answer