-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
net/http: Error when setting idleConnectionTimeout #70312
Comments
If I remove your custom dialer (you haven't given an implementation for it), the test passes. That leads me to believe the error is in your dialer implementation and not in net/http. |
The custom dialer does nothing but log an error if any. Here is the implementation
|
@seankhliao any other info required? |
It doesn't look reproducible elsewhere? |
I have not come across any other scenario |
I've tested it on both a Mac and Linux, neither can reproduce the issue. If no one else can, then it's on you to investigate/give us enough detail to identify a root cause. |
I see why you may not have been able to - the logger attempts to send it on the logger. Apologies - I had edited the code to print on console
This should show you the error on console now. Let me know if you are still not able to reproduce it |
can you please have a complete test case that we can just download and run? |
and the o/p on my console
|
if you look at the timing / call stack, that's the internals of net/http persistent connections getting shut down due to idle timeout. you can disable keepalives if you don't want them. closing as not a bug. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For questions please refer to https://github.com/golang/go/wiki/Questions |
but the internals of |
Go version
1.21
Output of
go env
in your module/workspace:What did you do?
If you set
IdleConnectionTImeout
timeout onhttp.Transport
to 2s. And send two separate requests with 5 seconds delay between them with custom logging dialer which logs an error received duringread
andwrite
operations onnet.Conn
We receive a
use of closed connection
error on sending the second request. The error is from theread
method onnet.Conn
. It seems like it was trying to reuse the first connection which was closed due to timeout. We expected Go to internally handle not reusing old connectionsHow to reproduce
What did you see happen?
use of closed network connection
What did you expect to see?
We expected a new connection would be used to read from the buffer. Instead it reuses an old connection that has already been closed due to timeout
The text was updated successfully, but these errors were encountered: