Andrei Pelinescu-Onciul writes:
Yes, ser will try first to reuse existing connection, but if for example you connect from foo:33001 to ser and then someone sends a message to foo or to foo:5060 ser will not find any match in its open connection list, so it will be forced to open a new one.
exactly this problem is solved by
http://www.ietf.org/internet-drafts/draft-ietf-sip-connect-reuse-00.txt
the trick is that if foo wants subsequent requests from the other party to arrive at port foo:33001, it adds parameter 'alias' to via header. when ser then receives the initial request that include 'alias' in the via header, ser's
transport layer creates an alias, such that any requests going to the "advertised address" (foo port 5060) are instead sent over the existing connection (to the "target" of the alias) which is coming from port 33001.
how difficult it would be to implement this in ser? we can very easily add 'alias' parameter to via sent by kphone.
Also all tcp connection will be closed (by ser) after some inactivity period (3 min).
the same i-d says:
This sharing continues as long as the target connection stays up. The SIP community recommends that servers keep connections up unless they need to reclaim resources, and that clients keep connections up as long as they are needed. Connection reuse works best when the client and the server maintain their connections for long periods of time. SIP entities therefore SHOULD NOT drop connections on completion of a transaction or termination of a dialog.
i.e., it might make sense to have a configurable max number of tcp connections and then start closing them based on longest inactivity when the limit is exceeded.
-- juha