Why are messages sent via WebRTC received in a different order?

I use an ordered set equal to true, however, when many (1000 or more) messages are sent in a short period of time (<1 second), the received messages are not all received in the same order.

rtcPeerConnection.createDataChannel("app", { ordered: true, maxPacketLifeTime: 3000 }); 

I could provide a minimal example to reproduce this strange behavior, if necessary.

I also use bufferedAmountLowThreshold and its related event to delay when the buffered send amount is too large. I chose 2000, but I do not know what the optimal number is. The reason I have so many messages in a short amount of time is because I don't want to overwhelm the maximum amount of data sent at one time. Therefore, I split the data into 800 byte packets and sent them. Again, I do not know what a message of maximum size 1 is.

 const SEND_BUFFERED_AMOUNT_LOW_THRESHOLD = 2000; //Bytes rtcSendDataChannel.bufferedAmountLowThreshold = SEND_BUFFERED_AMOUNT_LOW_THRESHOLD; const MAX_MESSAGE_SIZE = 800; 

Everything works fine for small data that is not split into too many messages. The error is executed randomly for large files only.

+5
source share
1 answer

In 2016/11/01, there is an error that allows you to change the value of dataChannel.bufferedAmount during the execution of the loop cycle task. Therefore, using this value may lead to unexpected results. You can manually cache dataChannel.bufferedAmount and use this to prevent this problem.

See https://bugs.chromium.org/p/webrtc/issues/detail?id=6628

+4
source

Source: https://habr.com/ru/post/1258919/


All Articles