-
Notifications
You must be signed in to change notification settings - Fork 1.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
Client.Do() returns EOF errors when reusing the Request and Response structs #15
Comments
@szank, a few remarks about your code snippets:
Client returns These are just my guesses. I could provide more info if you provide request and response headers sniffed on the connection. Hint you can use custom type sniffConn struct {
*net.Conn
}
func (c *sniffConn) Read(p []byte) (int, error) {
n, err := c.Conn.Read(p)
sniffData(p[:n])
return n, err
}
func (c *sniffConn) Write(p []byte) (int, error) {
n, err := c.Conn.Write(p)
sniffData(p[:n])
return n, err
}
func sniffDial(addr string) (net.Conn, error) {
c, err := net.Dial("tcp", addr)
if err != nil {
return nil, err
}
return &sniffConn{c}
} |
Wow, thanks for the long response :) I will modify my code to incorporate your tips and try again. Not all the requests are returning EOF, and I guess you are pretty close to truth with your guesses. |
I am not using the default client because I want to limit the maximum number of connections per host. Of course I could change the global MaxConnsPerHost value, but it doesn't "smell" nice, and if I change it after I call fasthttp.Do(), the effects will vary depending if the Client was taken from the pool or initialized. I will remove the dial func from the client, and dig into the haproxy though. |
FYI, fasthttp didn't send |
Hi, a small update :
A question about the I have used tcpdump and noticed, that sometimes after I send a request, the haproxy response with As the golang http package Now, calls like I am ok with checking for the Also, i wanted to say I didn't see any Regards, |
No, use
I should think more about this |
…est|Response)(Header)? only if the reader is closed before the first byte read
I returned to this issue and noticed that See added tests in referenced commits for details. So in your case the server was closing connection after returning response without explicit Closing this issue. |
…nection: close' response header before closing the connection
Now the client will return more meaningful |
Hi,
I am doing something like this :
in this use case, I am getting EOF errors for some reason. Could you please explain to me what I am doing wrong?
Before i was initiializing the http.Request inside of the loop, and calling default go http client Do() method.
I am running everything on my local machine, and there is haproxy between the client and server. I didn't see those problems if i don't connect through haproxy.
I am using fasthttp from commit e823a9a.
My fasthttp client struct looks like that :
The text was updated successfully, but these errors were encountered: