[ANNOUNCE] node-red-contrib-multipart-stream-decoder : version 1.0.0 beta

Bart, I just tried this on may Mac mini M1 and yikes (this happens in Safari, FireFox and Chrome).
First off the the first stream doesn't seem to be working (for me) so I added two more (flow attached) but when I start one then the other, they mix the images together
Screenshot 2023-01-31 at 9.25.46 AM
Screenshot 2023-01-31 at 9.30.57 AM
Screenshot 2023-01-31 at 9.32.09 AM
and I have to stop/start NR

It would seem that the decoder needs to know if it is already streaming and if so and it gets a new streaming request, it should end the first stream or reject the new request.

If there is anything I can do to test something let me know.

My flow with additional cameras:

[{"id":"78aa991a56a6ce2a","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"50a4d182a71cdf80","type":"inject","z":"78aa991a56a6ce2a","name":"Stop stream","props":[{"p":"stop","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","x":250,"y":360,"wires":[["8c35709.24b749"]]},{"id":"731c40362af5e27a","type":"inject","z":"78aa991a56a6ce2a","name":"Pause stream","props":[{"p":"pause","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","x":250,"y":260,"wires":[["8c35709.24b749"]]},{"id":"382a1962b0da9b0d","type":"inject","z":"78aa991a56a6ce2a","name":"Resume stream","props":[{"p":"resume","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","x":240,"y":320,"wires":[["8c35709.24b749"]]},{"id":"ee86d795.1e8cb8","type":"inject","z":"78aa991a56a6ce2a","name":"First stream (Czech Republic)","props":[{"p":"url","v":"http://89.203.137.209/mjpg/video.mjpg","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","x":160,"y":160,"wires":[["8c35709.24b749"]]},{"id":"8c35709.24b749","type":"multipart-decoder","z":"78aa991a56a6ce2a","name":"","ret":"bin","url":"","tls":"","authentication":"digest","delay":0,"maximum":"1000000","blockSize":"1","enableLog":"on","x":490,"y":160,"wires":[["a47f8c9bfe0c0793"],[]]},{"id":"a47f8c9bfe0c0793","type":"image","z":"78aa991a56a6ce2a","name":"","width":"400","data":"payload","dataType":"msg","thumbnail":false,"active":true,"pass":false,"outputs":0,"x":700,"y":160,"wires":[]},{"id":"c6cf7a07de508770","type":"inject","z":"78aa991a56a6ce2a","name":"Second stream (Marktplatz Austria)","props":[{"p":"url","v":"http://cam1.rauris.net/axis-cgi/mjpg/video.cgi","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":180,"y":200,"wires":[["8c35709.24b749"]]},{"id":"9c8ed7b176ae68c4","type":"catch","z":"78aa991a56a6ce2a","name":"","scope":null,"uncaught":false,"x":500,"y":240,"wires":[["b0e78cd2029b0d13"]]},{"id":"b0e78cd2029b0d13","type":"debug","z":"78aa991a56a6ce2a","name":"debug 9","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":500,"y":340,"wires":[]},{"id":"f7a685005c4729c2","type":"inject","z":"78aa991a56a6ce2a","name":"Bakery in  France","props":[{"p":"url","v":"http://185.194.123.84:8001/mjpg/video.mjpg","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":180,"y":80,"wires":[["8c35709.24b749"]]},{"id":"391c87e9d36520e5","type":"inject","z":"78aa991a56a6ce2a","name":"Reykjavik, Iceland","props":[{"p":"url","v":"http://212.30.240.7/mjpg/video.mjpg","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":40,"wires":[["8c35709.24b749"]]}]

Hi Bart,
Another issue is...
@zenofmud and myself have just updated our versions of your node to multipart-stream-decoder to v1.0.0 and are getting errors when we change a stream or stop a stream. As a test I'm using one of the flows off of your website. @krambriw has also confirmed he gets the same error indication.

walter_A

Hi @zenofmud,

Thanks for sharing the flow. I can confirm that I now finally can reproduce the issue. That is at least something to get started...

I see that the authentication method on the config screen is digest authentication. When I change the dropdown selection to "None", then it seems to be working fine in my case.

Not sure whether there is a problem in the @mhoc/axios-digest-auth library that I use on top of Axios. Or perhaps because your flow uses digest authentication without supplying digest credentials.

Could you check whether it works better with authentication type "None"?

@dynamicdave,

Could you share please some more details about that flow? With the flow from Paul above, I didn't get any of those errors. Thanks!

Bart, changing the configuration to none


got rid of the problem for me too!!

BUT (don't you just hate but's) when I get a stream running and press the 'stop stream' button the image stops on the screen- so far so good - but an error occurs that the catch node grabs and spits out in the debug log. Here is part of it:

CanceledError: canceled
    at EventTarget.abort (/Users/paul/.node-red/node_modules/node-red-contrib-multipart-stream-decoder/node_modules/axios/dist/node/axios.cjs:2380:54)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:731:20)
    at EventTarget.dispatchEvent (node:internal/event_target:673:26)
    at abortSignal (node:internal/abort_controller:308:10)
    at AbortController.abort (node:internal/abort_controller:338:5)
    at stopCurrentResponseStream (/Users/paul/.node-red/node_modules/node-red-contrib-multipart-stream-decoder/multipart_decoder.js:386:45)
    at MultiPartDecoder._inputCallback (/Users/paul/.node-red/node_modules/node-red-contrib-multipart-stream-decoder/multipart_decoder.js:510:17)
    at /usr/local/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:210:26
    at Object.trigger (/usr/local/lib/node_modules/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
    at Node._emitInput (/usr/local/lib/node_modules/node-...

Hi Bart - This is basically the flow on your web page but with different URLs.
@krambriw confirmed to me he gets the same errors when he uses the NR-flow.

My setup is a RPi-4B running Buster-OS.

When I switch from one stream to another or click the Stop button, I get an error reported.

This is the setting I'm using within the 'stream decoder'.
Bart_error_C_

[{"id":"a7a459ea5976ad90","type":"inject","z":"98da06e2e65af4df","name":"Stop stream","props":[{"p":"stop","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","x":230,"y":480,"wires":[["6016ba8d1ed71da2"]]},{"id":"6016ba8d1ed71da2","type":"multipart-decoder","z":"98da06e2e65af4df","name":"","ret":"bin","url":"","tls":"","authentication":"none","delay":"10","maximum":"1700000","blockSize":"1","enableLog":"off","x":490,"y":540,"wires":[["d192c5804936bc74"],["dee97e2cce4cc636"]]},{"id":"d192c5804936bc74","type":"image","z":"98da06e2e65af4df","name":"","width":"320","data":"payload","dataType":"msg","thumbnail":false,"active":true,"pass":false,"outputs":0,"x":740,"y":520,"wires":[]},{"id":"9ee23df09b57ecb5","type":"inject","z":"98da06e2e65af4df","name":"Norway ?","props":[{"p":"url","v":"http://79.141.146.81/mjpg/video.mjpg","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":220,"y":620,"wires":[["6016ba8d1ed71da2"]]},{"id":"dee97e2cce4cc636","type":"debug","z":"98da06e2e65af4df","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":490,"y":600,"wires":[]},{"id":"5aebd55a08297ff5","type":"inject","z":"98da06e2e65af4df","name":"Camera in Norway","props":[{"p":"url","v":"http://82.134.72.194/mjpg/video.mjpg","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":230,"y":540,"wires":[["6016ba8d1ed71da2"]]},{"id":"b5cb1627a26cee9c","type":"inject","z":"98da06e2e65af4df","name":"Bakery in Paris","props":[{"p":"url","v":"http://185.194.123.84:8001/mjpg/video.mjpg","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":220,"y":580,"wires":[["6016ba8d1ed71da2"]]}]

Just adding, I have always used "None" and I still see the same issue. The node however works as expected and completes it's task. It just seems it doesn't like the stream to be stopped the way it is. I did search your js code for the node but I could not find the text "CanceledError" so it might be as you suspect, could be it's coming from libraries you use

Best regards, Walter

@zenofmud, @dynamicdave, @krambriw,
Could one of you guys please install the node again from my Github account?
Hopefully the CanceledError is fixed.

Did some debugging and I think there is some legacy stuff mixed up in Axios: they have deprecated their CancelToken, and introducted a new AbortController (which I use to abort a running stream). But in this case aborting the stream, returns a "canceling" error message (instead of "aborting" which they sometimes trigger in other cases).

P.S. I haven't had a chance yet to start analyzing why the digest authentication failed.

2 Likes

Ohh that is working great on the test flow on my Mac mini! Even the STOP works now.

It also is working fine on Rpi 4 running the HSS project!

2 Likes

@BartButenaers : this latest works excellent here for me as well, thank you!

1 Like

Works fine for me as well.

Thanks Bart for sorting this out so quickly.

1 Like

I have added a fix on Github.
Damn that was an evening debugging through horrible event handling code.
Was getting nuts at the end. Couldn't figure why a stream with digest authentication couldn't be aborted. I arrived in completely different code from Axios. Until I realized that the axios-digest-auth library contains a very old axios version as a dependency. After passing my own recent axios instance to the digest auth constructor, the problem was solved.

Now I can finally fully control the mjpeg streams from my Amcrest camera's :partying_face: :tada: :champagne:

5 Likes

I have published version 1.0.1 on npm:

image

Like the expensive coach said at my daily job: "Good enough for now, good enough to go".
And two years later we are still paying the maintenance price for that advise :joy:

3 Likes

Hi Bart - Just looked on npm, still shows v1.0.0 - was v1.0.1 a typo?
bart

Ah yes that was a typo. Thanks for pointing that out!!