# Force disconnection of TCP connection

**URL:** <https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436>\
**Category:** General\
**Created:** [29 October 2023 07:40 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436 "2023-10-29T07:40:21Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 November 2023 11:05 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/21 "2023-11-03T11:05:55Z")

</div>

that is the in/out/reply pair... this is about the request node...

edit: hmm starting back at the start .. indeed it is about both... so more extensive fix needed... doh.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 November 2023 11:16 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/22 "2023-11-03T11:16:22Z")

</div>

@cymplecy - so in your case it's the in/reply pair. If we let msg.reset === true (and you already set \_session.id or not) then if we kill the connection (so no reply can be sent, ie any payload will be dropped) - and also the client is then free to reconnect if it wants.... presumably that is ok.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [3 November 2023 11:20 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/23 "2023-11-03T11:20:02Z")

</div>

Sounds good 🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 November 2023 11:58 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/24 "2023-11-03T11:58:02Z")

</div>

PR - updated - thanks all for the good discussion.

Now

- request node  
msg.reset = true; - resets all connections;.  
msg.reset = "host:port"; - just resets that specified connection.

- Out node in reply mode  
msg.reset = true; and no msg.\_session.id - resets all clients;  
msg.reset = true; and msg.\_session.id is set - resets specified client.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [3 November 2023 13:42 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/25 "2023-11-03T13:42:34Z")

</div>

Just copied your PR into an instance and it does what it says on the packet - pun intended 🙂

It force closed my MQTT connection

And then when the MQTT client tried to reconnect - it did so.

And then when I tried to force disconnect again - it didn't work - which was right because I was using the 1st \_session.id value in my inject node 🙂

updated to new \_session.id and it disconnected again 🙂

🙂

[edit]Additionally - made another connection from MQTT Explorer and then sent the disconnect to it with its \_session.id and it disconnected but my other connection stayed up 🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 November 2023 16:46 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/26 "2023-11-03T16:46:24Z")

</div>

That's great to hear. Thanks for the validation.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [3 November 2023 16:48 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/27 "2023-11-03T16:48:45Z")

</div>

Could I some more please....

...cough websocket node as well

.....runs away VERY quickly......

🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 November 2023 16:55 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/28 "2023-11-03T16:55:19Z")

</div>

too late - it's past gin o'clock... (in this house)

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [3 November 2023 16:57 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/29 "2023-11-03T16:57:10Z")

</div>

Let's not start this again! 😄

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 November 2023 17:02 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/30 "2023-11-03T17:02:59Z")

</div>

Hey - it's Friday ! just a fact...

---

<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:** [3 November 2023 18:01 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/31 "2023-11-03T18:01:57Z")

</div>

Dang I have to wait another couple hours again!

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [3 November 2023 18:04 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/32 "2023-11-03T18:04:55Z")

</div>

If its passed 10AM - your fine 😄

Liquid Brunch!

---

<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:** [2 January 2024 18:05 UTC](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436/33 "2024-01-02T18:05:33Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/force-disconnection-of-tcp-connection/82436.md?page=1)
