pocesar / node-jsonrpc2

JSON-RPC 2.0 server and client library, with HTTP (with Websocket support) and TCP endpoints
Other
105 stars 41 forks source link

TIME_WAIT #21

Closed kelchy closed 8 years ago

kelchy commented 9 years ago

is there a way to prevent this from creating too many TIME_WAIT sockets?

pocesar commented 9 years ago

yes, you can use a load balancer between the server and the outside world, like nginx (so you can reuse connections), but usually boils down to net configuration depending on your server. http://serverfault.com/questions/212093/how-to-reduce-number-of-sockets-in-time-wait

kelchy commented 9 years ago

Can't we just close the TCP port when a reply is received?

pocesar commented 9 years ago

TIME_WAIT happens after the connection is gone. we can't close the port manually, that's the OS layer that deals with this. the port is freed or reused after sometime, and since RPC is all about connection > request > payload > close, there's not much to do about it unless you tweak your server

kelchy commented 9 years ago

my rpc server don't have the time_wait issue. only on the nodejs side. This is the weird part, that means my server sent the reply and closed the connection. but on the nodejs side, it is stuck in time_wait state.

pocesar commented 9 years ago

all connections are closed after the request in http mode. socket, websocket and streaming keep the connection open for obvious reasons. time_wait happens when the local connection was closed but the other endpoint haven't