mqtt_as over websockets #17431
Replies: 3 comments 3 replies
-
The I don't think hacking |
Beta Was this translation helpful? Give feedback.
-
Yes, this is possible. I have implemented a client that does this. But I only have implemented the things I needed so it is not a ready to use product. Also concurrency is not a problem. Websocket has the advantage that packets arrive complete** in a websocket data packet, so there is no need to get every single byte and then decide what to do. (**according to the MQTT spec's it is possible that packets are split but I doubt if this ever happens). Also Websockets don't have the handshaking that normal http traffic has. Only in the beginning the handshaking is done, after that, you have a bidirectional link to work with. If you start using websockets you can use aiohttp from micropython-lib/python-ecosys. Be sure to use the latest version because it had a bug that I also fixed, see this issue micropython/micropython-lib#941 Keep in mind that aiohttp also uses getaddrinfo that is blocking. I have also made a async version of getaddrinfo but it is written in python. |
Beta Was this translation helpful? Give feedback.
-
Thx Jomas, I'll investigate in that direction.
Le dim. 8 juin 2025, 20:50, jomasnash ***@***.***> a écrit :
… Hi There, I'd like to know if it's possible to use mqtt_as over websockets
? I yes, does a howto exists somewhere ?
If no, would it be possible to implement in mqtt_as ? I can give it a try.
Thanks and regards,
Eric.
Yes, this is possible. I have implemented a client that does this. But I
only have implemented the things I needed so it is not a ready to use
product.
Also concurrency is not a problem.
Websocket has the advantage that packets arrive complete** in a websocket
data packet, so there is no need to get every single byte and then decide
what to do. (**according to the MQTT spec's it *is* possible that
packages are split but I doubt if this ever happens).
Also Websockets don't have the handshaking that normal http traffic has.
Only in the beginning the handshaking is done, after that, you have a
bidirectional link to work with.
If you start using websockets you can use aiohttp from
micropython-lib/python-ecosys. Be sure to use the latest version because it
had a bug that I also fixed, see this issue
micropython/micropython-lib#941
<micropython/micropython-lib#941>
In this issue there also is an example how to connect to a server over
websockets.
Keep in mind that aiohttp also uses getaddrinfo that is blocking. I have
also made a async version of getaddrinfo but it is written in python.
—
Reply to this email directly, view it on GitHub
<#17431 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEHMCZ6AWXVNGDZ2DGWTJCL3CSAXFAVCNFSM6AAAAAB6STSBHSVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGNBQGM3TIMQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi There,
I'd like to know if it's possible to use mqtt_as over websockets ? I yes, does a howto exists somewhere ?
If no, would it be possible to implement in mqtt_as ? I can give it a try.
Thanks and regards,
Eric.
Beta Was this translation helpful? Give feedback.
All reactions