5

I use ordered set to true, however when many (1000 or more) messages are sent in a short period of time (< 1 second) the messages received 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 the associated event to delay when the send buffered amount is too big. I chose 2000 but I don't know what the optimal number is. The reason I have so many messages in a short period of time is because I don't want to overflow the maximum amount of data sent at once. So I split the data into 800 Bytes packs and send those. Again I don't know what the maximum size 1 message can be.

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 occurs randomly for big files only.

4

1 回答 1

4

在 2016/11/01 中,有一个错误导致dataChannel.bufferedAmount事件循环任务执行期间值发生变化。因此,依赖此值可能会导致意外结果。可以手动缓存dataChannel.bufferedAmount,并使用它来防止此问题。

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

于 2016-11-01T14:41:17.030 回答