fabiolb / fabio

Consul Load-Balancing made simple
https://fabiolb.net
MIT License
7.26k stars 618 forks source link

TCP Proxy closes connection prematurely #336

Open Crypto89 opened 7 years ago

Crypto89 commented 7 years ago

There seems to be an issue with the tcp proxy, in the particular case that a client sends a “burst” of packages and immediately following a FIN after the request. at that point fabio closes the connection and the response is lost.

I think I tracked it down to https://github.com/fabiolb/fabio/blob/master/proxy/tcp/tcp_proxy.go#L73 it looks like the FIN triggers and EOF in fabio and then the connection gets closed by the defer. Ideally fabio should wait for the EOF on both sides before closing the connection.

I'm not sure about a proper solution which will cover this particular situation.

tomstaijen commented 7 years ago

Does that result in a "http: proxy error: context canceled" in the fabio output?

magiconair commented 7 years ago

@tomstaijen I doubt that since the tcp proxy is not using the http package.

@Crypto89 I have an idea on how to address this. There is a way to handle half-closed connections in Go.