# Trouble injecting a node

**URL:** <https://discourse.nodered.org/t/trouble-injecting-a-node/69975>\
**Category:** General\
**Tags:** modbus, function-node\
**Created:** [2 November 2022 16:23 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975 "2022-11-02T16:23:42Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![g.m.work](https://avatars.discourse-cdn.com/v4/letter/g/47e85d/32.png) [@g.m.work](https://discourse.nodered.org/u/g.m.work)\
**Post date:** [2 November 2022 16:23 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/1 "2022-11-02T16:23:43Z")

</div>

Hi,

I am trying to communicate to a modbus device using node red. The modbus device can only handle one request every 500 ms. My logic is working ok but it has issue initiating communication in the begining. The only way I am able to initiate communication is by using inject node and injecting a timestamp. Once the communication is initiated then everything works ok as per my script. Now I was hoping to use a "connect" button to inject timestamp and initiate comms but its not working. I checked the payload of my "connect" button and its identical to the inject node. So I dont understand why I am having issues.

![node-red inject issue - 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/28c33b029eb56a882451053e22792d7c609c68a1.jpeg)

![node-red inject issue - 2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/c/0c3a53f1078ce2ee92f5346b05369f1ba72d7499.jpeg)

---

<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:** [2 November 2022 17:53 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/2 "2022-11-02T17:53:27Z")

</div>

Set both debug nodes to Output complete message.

---

<div class="post-metadata">

**Author:** ![g.m.work](https://avatars.discourse-cdn.com/v4/letter/g/47e85d/32.png) [@g.m.work](https://discourse.nodered.org/u/g.m.work)\
**Post date:** [2 November 2022 18:42 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/3 "2022-11-02T18:42:48Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/342f7b644733ef9acbe3ce0dd26f520bf9360b27.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [2 November 2022 19:43 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/4 "2022-11-02T19:43:18Z")

</div>

Try adding a `change node between the button and ‘read 45…’ `function node. In the `change` node delete msg.event and see what happens.

---

<div class="post-metadata">

**Author:** ![g.m.work](https://avatars.discourse-cdn.com/v4/letter/g/47e85d/32.png) [@g.m.work](https://discourse.nodered.org/u/g.m.work)\
**Post date:** [2 November 2022 20:02 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/5 "2022-11-02T20:02:01Z")

</div>

Good idea. I just did that, now my message is identical to inject node and still it wont start the communication:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/e/2e73f9ef37d68f6a6393531ff8333b0eeb223573.png)

---

<div class="post-metadata">

**Author:** ![g.m.work](https://avatars.discourse-cdn.com/v4/letter/g/47e85d/32.png) [@g.m.work](https://discourse.nodered.org/u/g.m.work)\
**Post date:** [2 November 2022 20:04 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/6 "2022-11-02T20:04:39Z")

</div>

it seems the "socketid" format is quite different between the inject node (which is injecting timestamp) and the connect node (which is now connected to change node based on @zenofmud suggestion. I guess socket id would be different but dont know why they have different format of socket id.

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [2 November 2022 20:15 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/7 "2022-11-02T20:15:35Z")

</div>

Not quite, there is no `topic`. Not sure if/how this would make a difference but it's worth a try

---

<div class="post-metadata">

**Author:** ![g.m.work](https://avatars.discourse-cdn.com/v4/letter/g/47e85d/32.png) [@g.m.work](https://discourse.nodered.org/u/g.m.work)\
**Post date:** [2 November 2022 20:17 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/8 "2022-11-02T20:17:28Z")

</div>

I deleted both topic and event from the message:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/1/51eb3810ec427f5dd71b055c33ce1f8732058df3.png)

Still no change :(.

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [2 November 2022 20:28 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/9 "2022-11-02T20:28:44Z")

</div>

Sorry I meant that in the output shown in the images above the `inject node` has a `topic` but the connect button does not, Try adding a `topic` to the connect button. As I said I cannot see how this would make a difference but...

---

<div class="post-metadata">

**Author:** ![g.m.work](https://avatars.discourse-cdn.com/v4/letter/g/47e85d/32.png) [@g.m.work](https://discourse.nodered.org/u/g.m.work)\
**Post date:** [2 November 2022 20:32 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/10 "2022-11-02T20:32:55Z")

</div>

Sorry, my bad. Alright I just made that change and still no effect:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/0/3051901f76668d509beb2fa8798e720fcf0d6a8f.png)

Guess I am out of options now ...

---

<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:** [2 November 2022 20:53 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/11 "2022-11-02T20:53:13Z")

</div>

What happens if you disconnect the button from the function node directly next to it?

---

<div class="post-metadata">

**Author:** ![g.m.work](https://avatars.discourse-cdn.com/v4/letter/g/47e85d/32.png) [@g.m.work](https://discourse.nodered.org/u/g.m.work)\
**Post date:** [2 November 2022 20:58 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/12 "2022-11-02T20:58:31Z")

</div>

@Colin That's it. This change did the trick! Thank you!

I basically added one more button. So I use one to set IP address for my modbus connector node and then second one for initiating connection. here is the solution.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/8/f88998fbeea6a7a0e26d80eedf0acfcbf7fc7870.png)

---

<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:** [2 November 2022 21:22 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/13 "2022-11-02T21:22:52Z")

</div>

Do you want to do it like that or do you want it automated? If you have something that has to run on startup then you can use an Inject node set to fire on startup.

Can't you set the IP in the getter node, or is it not always the same?

---

<div class="post-metadata">

**Author:** ![g.m.work](https://avatars.discourse-cdn.com/v4/letter/g/47e85d/32.png) [@g.m.work](https://discourse.nodered.org/u/g.m.work)\
**Post date:** [2 November 2022 23:03 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/14 "2022-11-02T23:03:50Z")

</div>

the device node-red will be talking to can have different IP. So I dont want it automated. Moreover, I am reading from different address location so managing that with a specific interval set within inject node is not ideal. Rest of my logic is working ok. I verified using wireshark!

Thanks again!

---

<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:** [16 November 2022 23:04 UTC](https://discourse.nodered.org/t/trouble-injecting-a-node/69975/15 "2022-11-16T23:04:00Z")

</div>

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