mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[GH-ISSUE #1192] Connection interuption results in partially written content body #936
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#936
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jsheely on GitHub (Apr 10, 2019).
Original GitHub issue: https://github.com/fatedier/frp/issues/1192
Originally assigned to: @fatedier, @yuyulei on GitHub.
What version of frp are you using (./frpc -v or ./frps -v)?
v0.25.3
What operating system and processor architecture are you using (
go env)?Windows
Steps to reproduce the issue:
Client -> FRP Server -> FRP Client -> API
Client -> FRP Server -> (Internet Outage) -> FRP Client -> API
Describe the results you received:
If the connection between FRP Server and FRP Client is broken (internet outage) while content body is streaming FRP will close the partially completed stream successfully and your result will be half complete
Describe the results you expected:
If the connection between FRP Server and FRP Client is interupted in the middle of the stream the connection from FRP Server to Client should be disconnected. This will result in an "Error while copying content to a stream" in most standard HTTP clients so the error can be handled gracefully
@fatedier commented on GitHub (Apr 12, 2019):
I'm not sure what is the problem.
Internet Outage can be detect by heartbeat between frps and frpc. So frpc will close old connection and create a new one.
HTTP clients should have their own timeout way to prevent this problem?
@jsheely commented on GitHub (Apr 12, 2019):
@fatedier So the issue is that if the connection goes down while a file is being streamed FRP ends the stream succesfully as if everything was fine and that was the end of the file. Even if only half the file got transmitted
The http client does not know that FRP Server lost connection to FRP Client in the middle of the stream because FRP server is returning successfully.
The HTTP Client at this point doesn't know the difference between a stream ending because it has all the data or that the stream ended prematurely and it only has half the data because FRP in both cases flushes the stream the same way.
Hope that helps explain the issue more.
@fatedier commented on GitHub (Apr 12, 2019):
I have different ideas.
Why does HTTP client think it has the complete file content while the length of bytes it read is not equal with
Content-Length?What's the meaning of
returning successfully? If the connection from FRP server to client is broken, frps will close the connections from HTTP client. I think the normal HTTP client should return a unexpected EOF since it hasn't read all of the content.@jsheely commented on GitHub (Apr 12, 2019):
That is the correct behavior.
If the connection is closed during a content stream from Http Client -> FRP Server then it will throw an exception correctly
However if the connection is closed from the FRP Server -> FRP Client then the Http Client is given a partial response and no exception is raised.
These two scenarios should be treated the same so the client is given the exception
@jsheely commented on GitHub (Apr 12, 2019):
Here is a code example of the HTTP Client in C# .net core and where the issue shows up
@fatedier commented on GitHub (Apr 12, 2019):
Thanks for your example code. I will test it when i have a free time.
I still have a question. What's your scenarios when you say the connection is down, frpc is down(like being killed) or network interruption ?
@jsheely commented on GitHub (Apr 12, 2019):
@fatedier Connection interuption
I just tested the scenario again and now I am confused. Because using the latest v0.26 the issue is now happening
If I close the FRP Client manually then I get the error I expect on the Http Client
Error while copying content to a stream.So either this was fixed in v0.26 or my scenario in production is different then in testing.
I will keep testing and see if I can get some more information for you. Perhaps this is no longer a problem
Thank you!
@fatedier commented on GitHub (Apr 12, 2019):
There are some differences between the two scenarios.
@jsheely commented on GitHub (Apr 12, 2019):
Oh yes good point.
So I did end up testing that and in both scenarios if I manually close FRPC or if I just kill the process. It's sending the
[newhttp.go:221] httputil: ReverseProxy read error during body copy: unexpected EOFto FRPS and my Http Client is gettingError while copying content to a stream.Which is perfect and how I expect it to work. But this is still not the behavior I'm seeing in my production environment. So I will keep testing.
At this point I believe FRP is handling the scenario correctly and it is either a edge case or a problem in my environment.
Thank you again for your assistance. It's much appreciated.
@jsheely commented on GitHub (Apr 12, 2019):
Okay I have some more details
Transfer-Encoding: chunkedis set and the API does not return a content-length then what is happening is that it's not looking for the content termination character which says that it has received all the contentSo in the case that the stream cuts out and it hasn't received that stream ending character then it should also throw an EOF exception and kill the connection as it does in the other two scenarios.
@fatedier commented on GitHub (Apr 15, 2019):
I think your c# http client doesn't handler
chunkedstream correctly.From https://en.wikipedia.org/wiki/Chunked_transfer_encoding
HTTP client should return unexpect EOF after the connection closed when it hasn't received the last zero-length chunk.
@meluskyc commented on GitHub (May 17, 2019):
Hello,
I was able to reproduce this issue using the
go httpclient and alsocurl. See the sample code here.Here is the expected behavior. When using
ngrokand killing thengrokclient during transmission of a chunked response, thegohttp client errors withunexpected EOF. curl returns error18:When running
frpsand killingfrpcduring transmission, thegohttp client does not error.curlreturns no errors:@yuyulei commented on GitHub (Nov 5, 2020):
@jsheely @meluskyc fixed by PR#2051,please try next release。