# In Node-red how to close tcp session

**URL:** https://discourse.nodered.org/t/in-node-red-how-to-close-tcp-session/50719
**Category:** General
**Created:** [7 September 2021 18:04 UTC](https://discourse.nodered.org/t/in-node-red-how-to-close-tcp-session/50719 "2021-09-07T18:04:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rahul123-dotcom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rahul123-dotcom/32/46865_2.png) [@rahul123-dotcom](https://discourse.nodered.org/u/rahul123-dotcom)
#### Post date: [7 September 2021 18:04 UTC](https://discourse.nodered.org/t/in-node-red-how-to-close-tcp-session/50719/1 "2021-09-07T18:04:17Z")

</div>

Using node-red I am integrating teltonika GPS device([Teltonika Data Sending Protocols - Wiki Knowledge Base | Teltonika GPS](https://wiki.teltonika-gps.com/view/Teltonika_Data_Sending_Protocols)). In node-red I am receiving data through tcp listener node . Whenever the device creates connection it will first send imei number and I am storing that in redis like` sessionid:imei number`(session id as key and imei as value). So, I need to send reply packet for acceptance of connection like 1 or 0. If accepted device will send the gps tracking data based on the `sessionid` I am fetching imei from redis and enriching the data with imei number and pushing to the next processing layer.

But while storing redis I am storing with key expiry. So, each time whenever I am listening data I am updating expiry for the session key. So, if teltonica device is not sending the data for 2 hour I am deleting the key from redis. So, how can I terminate the session from node-red on redis expiry or is any other better approach which I can follow.

---

<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: [6 November 2021 18:04 UTC](https://discourse.nodered.org/t/in-node-red-how-to-close-tcp-session/50719/2 "2021-11-06T18:04:22Z")

</div>

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