iiot2k / gpiox

Raspberry Pi gpiox node.js and C++ library
Apache License 2.0
1 stars 0 forks source link

node red not reacting when more than three gpiox-in #1

Closed mhin76 closed 1 month ago

mhin76 commented 2 months ago

I noticed, that when I use three gpiox-in all works just fine (in addition I use several gpiox.out). but as soon as I add another gpiox-in, nodered hangs on the second deployment! Means, first deployment all fine, when I change anything in node red and I want to reploy it is not reacting anymore and I have to kill the node red session, set that flow to disabled via flows.json file and restart node red again. I do not see any message on node red debugging (on info level).

is there a max on those listener? any idea how I could further debug?

PS: I am using raspberry 4 with bookworm

iiot2k commented 1 month ago

Hello, sorry for the late reply. That is really very interesting. Thank you for your tip. I'll try to recreate it. Can you also tell me the version of the OS, node.js and Node-Red? Best regards Viele Grüße Derya

mhin76 commented 1 month ago

I run bookworm (Linux kernel 6.6.31) on a RP5 with NodeRed v3.1.9 and node.js v20.15.0. Sonnige Grüsse, Martin

iiot2k commented 1 month ago

Hi Martin, can you send me your Node-Red Flow to my e-mail address ? Thanks! Viele Grüße Derya

FlamingFury321 commented 1 month ago

I have the same issue. The selected pin doesn't matter but as soon as I enable the 4th GPIO Node (even when not connected) it hangs and i cannot deploy anything anymore. After 30 seconds I get an "Error: connect ETIMEDOUT" error on one of my mysql nodes (even though it isn't connected in any way to the GPIO node). LG Daniel

mhin76 commented 1 month ago

yes, exactly same behavior. I have then to disable that flow via nano flows.json and restart node red to get in again. Attached my flow. flows (3).json

those 5 at the bottom I tried to enable. Three of them I kept disabled.

No hurry about the fix. for me not so urgent at least :)

mhin76 commented 1 month ago

Hallo Derya

Oohhhhh, das tut mir leid zu hören!! Ich wünsche dir viel Erfolg bei der nächsten Tür, die dadurch aufgeht!!

Fix ist überhaupt nicht eilig für mich.

Sonnige Grüsse, Martin

From: Derya Y. @.> Sent: Montag, 8. Juli 2024 15:41 To: iiot2k/gpiox @.> Cc: Martin Hinz @.>; Author @.> Subject: Re: [iiot2k/gpiox] node red not reacting when more than three gpiox-in (Issue #1)

Hallo Martin, Hallo Daniel, habe gestern meine Kündigung erhalten. Muss mich etwas gedanklich beruhigen. Aber natürlich muss dieser Fehler behoben werden. Wenn Ihr wollt, kann ich euch die Quelldateien zusenden. Schreibt mir zu iiot2k @ gmail . com LG Derya

— Reply to this email directly, view it on GitHub https://github.com/iiot2k/gpiox/issues/1#issuecomment-2214110113 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ALXOFW25WYYBZFNMTZVIJV3ZLKJHHAVCNFSM6AAAAABJKBL3WCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJUGEYTAMJRGM . You are receiving this because you authored the thread. https://github.com/notifications/beacon/ALXOFW7GETRVEFFBUG5VDJDZLKJHHA5CNFSM6AAAAABJKBL3WCWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUD7CR2C.gif Message ID: @. @.> >

iiot2k commented 1 month ago

Hello, the problem is UV_THREADPOOL_SIZE in node.js. This value is set to 4 by default. That's why you can't call any more watches. You can set this environment variable up to 1024, but that's not the solution. I'll probably have to rewrite the code.

Here is the issue: https://github.com/nodejs/node-addon-api/issues/1539

Best regards Derya

iiot2k commented 1 month ago

Fix watch_gpio 🐛

The watch_gpio function only accepts a few gpio watches.
The reason is that the gpio watches run in the background as a thread.
Unfortunately, the maximum number of threads is set to 4.
One solution is to increase this number of threads.
With the command:

export UV_THREADPOOL_SIZE=1000

You can increase this number of threads (max. 1024) for node.js.
Of course, this number of threads also increases the memory requirement.
Try other numbers of threads too.
This also applies to the Node-Red node.
All other functions work correctly.

iiot2k commented 1 month ago

Solved with Version 2.1.3 Thanks to all who helped.