Hi all,
I am using dispatch json to get a json stream from jetty, but server is not closing the connection and after some time application is getting java.net.SocketException: Too many open files. following trace from http commons log while initiating the connection, DEBUG headers - [Thread-445] [] >> Connection: Keep-Alive DEBUG wire - [Thread-445] [] << "HTTP/1.1 200 OK[EOL]" DEBUG wire - [Thread-445] [] << "Content-Type: application/json;charset=UTF-8[EOL]" DEBUG wire - [Thread-445] [] << "Content-Length: 3104[EOL]" DEBUG wire - [Thread-445] [] << "Server: Jetty(8.0.0.M1)[EOL]" DEBUG wire - [Thread-445] [] << "[EOL]" DEBUG DefaultClientConnection - [Thread-445] [] Receiving response: HTTP/1.1 200 OK DEBUG headers - [Thread-445] [] << HTTP/1.1 200 OK DEBUG headers - [Thread-445] [] << Content-Type: application/json;charset=UTF-8 DEBUG headers - [Thread-445] [] << Content-Length: 3104 DEBUG headers - [Thread-445] [] << Server: Jetty(8.0.0.M1) DEBUG ConfiguredHttpClient - [Thread-445] [] Connection can be kept alive indefinitely 1) how can i close the underlaying http connection from dispatch, 2) if server support connection reuse, how can i enable connection reuse ? my code look like , val http = new Http val response = http("http://localhost:8080/test" as_str) ... thanks, -Andy J |
Administrator
|
If you are creating new client instances for each use, could you try shutting down the connection manager when you are done with each? http.client.getConnectionManager.shutdown() If that works, I'd also like to know if setting a different ConnectionKeepAliveStrategy works without calling shutdown. We've never had to call shutdown explicitly through Dispatch (though this doc page I just found says you "must" [1]) and I do suspect some defaults have changed underneath it. [1]: http://hc.apache.org/httpcomponents-client-ga/tutorial/html/httpagent.html Nathan On 05/20/2011 01:14 AM, Andy [via Databinder] wrote: Hi all, |
Free forum by Nabble | Edit this page |