# When using socket CAN node red event loop is blocking

**URL:** <https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972>\
**Category:** General\
**Tags:** function-node\
**Created:** [7 November 2024 14:54 UTC](https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972 "2024-11-07T14:54:35Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbhanu368](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@pbhanu368](https://discourse.nodered.org/u/pbhanu368)\
**Post date:** [7 November 2024 14:54 UTC](https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972/1 "2024-11-07T14:54:35Z")

</div>

[flows (60).json](https://discourse.nodered.org/uploads/short-url/sw5wPDTvy7Z5MlkvuEAjK9Oy5zC.json) (104.4 KB)

Im sending 12 broadcast requests from socket can for every 250ms, parallely 6 devices will repond with 36 responses

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 November 2024 15:01 UTC](https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972/2 "2024-11-07T15:01:30Z")

</div>

Please provide more detail

For 1: Adding your flows is of little use to people who dont have your devices or dont use the CAN nodes. But at a guess, try slowing them down or staggering the requests to run in sequence instead of parallel.

Can you identify the CAN node full package in the [flows library](https://flows.nodered.org/)?

How do you know it is "blocking"?

---

<div class="post-metadata">

**Author:** ![pbhanu368](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@pbhanu368](https://discourse.nodered.org/u/pbhanu368)\
**Post date:** [7 November 2024 16:01 UTC](https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972/3 "2024-11-07T16:01:55Z")

</div>

Yes it is there in flows library,

whenever I function node at socket can rx node, its event loop is blocking.  
Im using blockify js module to detect event loop pauses

I just want to know one thing the function node receiving bulk data from socket can rx node, whether it will block the event loop or run the function node asynchrnously ?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 November 2024 16:05 UTC](https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972/4 "2024-11-07T16:05:04Z")

</div>

> [@pbhanu368](#):
>
> Yes it is there in flows library,

Which one!

> [@pbhanu368](#):
>
> whenever I function node at socket can rx node, its event loop is blocking.  
> Im using blockify js module to detect event loop pauses

Show us how.

> [@pbhanu368](#):
>
> I just want to know one thing the function node receiving bulk data from socket can rx node, whether it will block the event loop or run the function node asynchrnously

If it is running a hard loop inside the blockly generated code, then YES, looping is (probably) synchronous and WILL block. However, it would have to be rather large to be noticeable.

* * *

As with your other thread, there simply isnt enough information to give to definitive answers or solutions.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 November 2024 16:09 UTC](https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972/5 "2024-11-07T16:09:30Z")

</div>

> [@pbhanu368](#):
>
> the function node receiving bulk data from socket can rx node, whether it will block the event loop or run the function node asynchrnously ?

In order to check whether your function node is causing the block then, as suggested in your other thread, remove all wires from the can nodes' outputs and just connect to debug nodes. Then see if it still blocks.

---

<div class="post-metadata">

**Author:** ![pbhanu368](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@pbhanu368](https://discourse.nodered.org/u/pbhanu368)\
**Post date:** [7 November 2024 16:14 UTC](https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972/6 "2024-11-07T16:14:16Z")

</div>

[flows (53).json](https://discourse.nodered.org/uploads/short-url/2gNT4DmljfgEJiXgkNA8iweNWtX.json) (91.9 KB)  
Import this flow and check

Ignore previous flow whichever i have given

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 November 2024 16:15 UTC](https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972/7 "2024-11-07T16:15:42Z")

</div>

> [@pbhanu368](#):
>
> Import this flow and check

No thank you. I dont use Blockly or CAN nodes & I am not installing them on my Node-RED.

If you want further help, please answer the questions.

---

<div class="post-metadata">

**Author:** ![pbhanu368](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@pbhanu368](https://discourse.nodered.org/u/pbhanu368)\
**Post date:** [7 November 2024 17:09 UTC](https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972/8 "2024-11-07T17:09:34Z")

</div>

I removed all wires from function node coming out from the socket can output node, and added debug node then the event loop is not blocking

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 November 2024 18:46 UTC](https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972/9 "2024-11-07T18:46:30Z")

</div>

So it is not the CAN node causing the problem, it is something downstream from there.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 February 2025 18:47 UTC](https://discourse.nodered.org/t/when-using-socket-can-node-red-event-loop-is-blocking/92972/10 "2025-02-05T18:47:20Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
