Reputation: 1
The LiveKit documentation has this note regarding publishing data over the 'Reliable' WebRTC data channel:
note
Reliable delivery indicates "best-effort" delivery. It cannot fully guarantee the message will be delivered in all cases. For instance, a receiver that is temporarily disconnected at the moment the message is sent will not receive it. Messages are not buffered on the server and only a limited number of retransmissions are attempted.
Having missing or unordered messages can throw a loop in my application logic. For example: chunked file transfers & implementing higher level handshakes over the data channel.
I've naively tried to fix this by incrementing a counter on the sending and receiving peers, and sending that counter along with each message over the data channel. When an incoming message skips ahead of the receiver's counter, the receiver will queue messages until the missing one(s) come in. That works great assuming messages never get lost! Of course, they do get lost without warning when one peer or the other changes wifi networks or cell towers or reloads the webpage! Using message acknowledgements would work here, but properly implementing ACKs to minimize edge cases and bandwidth congestion is not straightforward.
I know there are many protocols out there that solve this problem and took years to get right like MQTT, ZeroMQ, TCP, & QUIC. However, I couldn't find a library or protocol that has support for web browsers without a backend over arbitrary transports like Livekit WebRTC data channels.
Q: Does such a Javascript library exist? If not, what is the best approach to implement this and what are the gotchas that this approach avoids or that I need to handle?
Simplifying assumptions I can make:
Other things I've thought about:
Upvotes: 0
Views: 110