http://qs321.pair.com?node_id=800587


in reply to How to keep network connection persistent during session?

HTTP just doesn't work that way. Aside from that, even if you could serialize a network connection (which you can't) it won't help you do what you want to do.

If you want to use HTTP, the best easily achievable goal is to use Keep-alive on the connection (which AFAIK any decent webserver should support / suggest / do already by default, but it may help to test it and/or increase the timeout. This won't help you with the authentication part, since HTTP doesn't guarantee that single connections serve only a single session - it's even possible that in between proxies could "bundle" multiple sessions over a single connection (though I don't know of any proxy that does that).

In any case, IME if authentication/reconnection takes such a large part of your system, you're either doing it wrong, or you're not doing anything very interesting.

If you're really that pressed for processing power, switch to a protocol that's a little less designed for single request/response actions and more designed for long-term connections. Like STOMP. Of course, that means ditching a pure web based approach...