-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket closed after each request #5
Comments
I removed the disconnect() call. As much as I can gather, it is not necessary and probably shouldn't be there. We don't normally need to free the resources (socket) in our case. We might need to make this configurable in the future if it turns out this consumes too many resources in some cases. |
nice, thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently the socket is closed after each request by HttpTemplate.executeRequest -> connection.disconnect()
The problem is that if a connection has a keep-alive header it would automatically be cached and this disconnect prevents this.
I'm now quite sure if the disconnect can just be removed or if it should just be skipped for keep alive requests.
What is the best way to solve this problem?
FYI:
Here is the description for disconnect from the JavaDoc:
Indicates that other requests to the server are unlikely in the near future.
Here are some infos how the connection is cached:
http://docs.oracle.com/javase/6/docs/technotes/guides/net/http-keepalive.html
And some other infos for the HttpUrlConnection:
Each HttpURLConnection instance is used to make a single request but the underlying network connection to the HTTP server may be transparently shared by other instances. Calling the close() methods on the InputStream or OutputStream of an HttpURLConnection after a request may free network resources associated with this instance but has no effect on any shared persistent connection. Calling the disconnect() method may close the underlying socket if a persistent connection is otherwise idle at that time.
The text was updated successfully, but these errors were encountered: