Search code examples
javascriptnode.jstcpstreambuffer

Node-red how to identify a stream when listening on the same por


I am using Node-Red to listen TCP on specific port (buffer), receive data from GPS trackers and save them to MySQL db. This works fine for one device.

node-red settings

The thing is that, when multiple devices are sending data to the same IP/PORT how can I know that they are more then one device (devices are not sending IMEIs, serials, etc.).

Is there any solution which shows me something like IP of incoming connection, connection id or idenitificator of session?

Or I am missing something important?


Solution

  • Ok, I can now answer my own question. I have found that we can use session id:

    var session = msg._session.id;
    

    If you know the session ID you can identify few different connections.