Do Node red http requests open new socket for each request to same ip and port

I used http request node to request to my device. I am requesting to same device every second. Does this request process open the new socket for each request or it uses existing socket (same IP and Port Number)?

To be pedantic, I don't think that you are opening a "socket". But I would expect the http request node to create a new request each time as this is how you would expect simple HTTP to work. To get smarter than that, I think that you need TLS.

If you want something more, you will need to look at using websockets rather than http requests.

So for every new request is it using existing socket if ip address is same ?
i am using https node and analyze it on wire shark but it is creating new socket for each request i mean port number for src port getting change for each time how to prevent this?
any idea?

It isn't a socket, it is a request. A new request is created each time, that's how HTTP works in general. I believe there are now alternatives but they aren't the default methods & I don't believe the http request node has those capabilities.

HTTP/2 has the ability to share connections but that is for different resources (in parallel) rather than subsequent requests. It also supports things like header compression and server push. All things that can reduce the number of separate requests which is expensive - especially when TLS is involved. HTTP/2 though requires TLS.

To get HTTP/2 working with ExpressJS that Node-RED uses, the spdy package would be needed.

However, even that - I don't think - would do what you are expecting as I don't think HTTP fundamentally works that way (of course, I could be wrong as I'm not an expert in this area).

Websockets, on the other hand is precisely for this purpose. You make a single connection over http(s) and then upgrade to ws(s) and the connection is maintained allowing long-term exchange of data without needing further connections to be made.

This is inherent to networking. The webserver needs a way back to the origin it does this by responding on port number. New request = new port assignment.

Things to consider:

  • Can the 'every second' be reduced ?
  • is the destination device not capable of sending data directly on a static port ? (instead of requesting every second)

i observe when i creating requests from javascript to device it is using same session. How use spdy in node red as node? ,My simple question is how to make https request in node red such that for each repetitive request with same ip not change the session

i want enable TLS session resumption for https request in node.js. how to enable that ? and how node red use that TLS session resumption ? any node use that

and For request it is create socket in background @TotallyInformation