k-yle / sACN

💡 🎭 Send & Receive sACN data (DMX over IP) in node.js
https://npm.im/sacn
Apache License 2.0
28 stars 12 forks source link

Bug: Out of order wrap around requires specific sequence value #37

Closed benjaminauer closed 2 years ago

benjaminauer commented 3 years ago

When sequence does not go up to 255, skips it for any reason, the sequence gets out of order for the remainder of the duration the process is running.

https://github.com/k-yle/sACN/blob/eae3d83fc07a57a13b926fc40d46f445bb599d55/src/receiver.ts#L65-L66

k-yle commented 3 years ago

Hi @benjaminauer, I've opened #38 which should fix this - only one error will be emitted, then it will use the latest sequence. let me know if that PR works for you. Otherwise I'll release the fix tomorrow

benjaminauer commented 3 years ago

will be able to check it on friday 16.07.21 found the issue when every second packet was always tagged with packetcorruption. sender is an ETC paradigm processor. i will try to track the issue down and create another issue later on

benjaminauer commented 3 years ago

i could not try it in my theatre today, but i tried some stuff at home now, they way this lib handles the packet sequence, it will throw an error, when multiple senders are active in a network. it needs a per source / per universe comparsion to check order of packets

hansSchall commented 2 years ago

Having the same bug with a ETC IonXE20 Eos 3.1.0 Build 282 and sACN Version 4.1.0

My Software is listening to universe 2, Ion is transmitting universe 2, Another Device is transmitting universe 1.

Log looks like this:

Error: Packet significantly out of order in universe 2 (254 -> 27) at Socket. (D:\technik\software\sACN2Video\server\node_modules\sacn\dist\receiver.js:26:27) at Socket.emit (node:events:390:28) at UDP.onMessage [as onmessage] (node:dgram:939:8) Error: Packet significantly out of order in universe 2 (254 -> 28) at Socket. (D:\technik\software\sACN2Video\server\node_modules\sacn\dist\receiver.js:26:27) at Socket.emit (node:events:390:28) at UDP.onMessage [as onmessage] (node:dgram:939:8) Error: Packet significantly out of order in universe 2 (254 -> 30) at Socket. (D:\technik\software\sACN2Video\server\node_modules\sacn\dist\receiver.js:26:27) at Socket.emit (node:events:390:28) at UDP.onMessage [as onmessage] (node:dgram:939:8) Error: Packet significantly out of order in universe 2 (254 -> 31) at Socket. (D:\technik\software\sACN2Video\server\node_modules\sacn\dist\receiver.js:26:27) at Socket.emit (node:events:390:28) at UDP.onMessage [as onmessage] (node:dgram:939:8) Error: Packet significantly out of order in universe 2 (254 -> 32) at Socket. (D:\technik\software\sACN2Video\server\node_modules\sacn\dist\receiver.js:26:27) at Socket.emit (node:events:390:28) at UDP.onMessage [as onmessage] (node:dgram:939:8)

and so on from 1 to 233

Sometimes I get this error, sometimes not.

I will try to get a log of all the sACN messages.

benjaminauer commented 2 years ago

@hansSchall, it should be fixed with the #38 have you tried it? Should only throw one error and then update the order index.

hansSchall commented 2 years ago

I've tried out the bugfix and it works.

There are only single frames dropped, which aren't noticed.

But I can imagine this fix could cause strange behavior in case there is a real packet corruption. It shoud be possible to disable this with a flag like this:

const sACN = new Receiver({
  universes: [1, 2],
  enableFewerOutOfOrderErrors: false,
});

and a notice in the readme.md like this:

this option needs to be enabled for some senders (especially ETC's devices), but could cause strange behavior in some circumstances

k-yle commented 2 years ago

I've updated PR #38 so that there should be no PacketOutOfOrder errors if there are two consoles broadcasting to the same universe. Tested with one laptop running Martin M-PC and another laptop running LightFactory.

I'm going to merge #38 tomorrow since this seems to properly fix the issue.

@hansSchall, this means we won't need the flag you suggested