How to deny a tcp connection

I have written a small, specialized version of a "MQTT Server". The only thing it can is to distribute logic states and numbers to all connected systems.
The UI lets you declare, which ip-addresses are allowed (and by that which are not allowed).
I have limited the number of cennoctions - well not really - to 12 known addresses, only messages from these devices will be distributed to all open connections.
The problem is: the tcp server acceps all connections, i need to filter the unwanted devices, but the unwanted connection could be still alive.
My question is: how can i close a connection from a device that is not in my list?

If you are using your own node.js tcp code you can use socket.destroy() to terminate the connection.

My own node.js tcp code ???
No, i use the node-red tcp in and tcp out node.
I will look what i can find about node.js tcp code.

sorry - when you said you had written a small specialised version I assumed you were creating your own node. So yes - the existing TCP nodes do not allow you to force a disconnection.

Thank you for the answer, i love clear statements ( even if the content is a little bit disappointing ... ).
Where could i find a sample of creating it with nodejs? I found some very simple code examples, but i would not know how to integrate it in node-red.

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