Skip to content
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

Server emitting errors and traceback on ECONNRESET when it should be a warning. #763

Closed
ashleysommer opened this issue Sep 21, 2021 · 3 comments · Fixed by #764
Closed

Comments

@ashleysommer
Copy link
Contributor

ashleysommer commented Sep 21, 2021

Using versions:
Julia 1.6
HTTP.jl 0.9.14

It appears the intention of this code in Servers.jl is to throw a warning rather than an error when the connection is reset by the peer (ie, client closed the connection to our server).

However this is done by a check on the error code. And this code seems to change based on the architecture of the system running. On my system, ECONNRESET corresponds with e.code of -104.

See this list of search results for "connection reset by peer" in the linux source code:
https://github.com/torvalds/linux/search?p=1&q=%22connection+reset+by+peer%22&type=code

Notice lots of different errno.h files.

  • For SPARC and ALPHA architectures, ECONNRESET is 54 (as per the code in Julia)
  • For Generic architecture, ECONNERESET is 104 (this is what my system is, and probably 99% of users)
  • For PARISC architecture, ECONNRESET is 232
  • For MIPS architecture, ECONNRESET is 131

Note, when the TCP driver throws these exceptions, it makes them negative, so Julia must match on the negative value, eg -104.

I don't know why -4077 is in the code, it doesn't match any error number I could find, maybe thats the one windows uses?

Related to #547
Tangentially related to #657 (in the sense that an error is propagated in a non-actionable way)

@ashleysommer
Copy link
Contributor Author

This comment on #547 also mentions their code is -104, and suggests the code can change between platforms.

@ashleysommer
Copy link
Contributor Author

I just performed a local build of this library, with the -54 changed to -104 and it fixed some major server issues I was seeing due to propagation of that error.

@ashleysommer
Copy link
Contributor Author

ashleysommer commented Sep 21, 2021

Ok, I'm now pretty sure the code -4077 is used on Windows, so makes sense to have that in there.
I don't know for certain, but I guess the -54 code is used on MacOS? Because I'm certain the devs of this library are not using SPARC or ALPHA based processors.

From what I can tell by looking at code overlaps, it should be pretty safe to just naively write e.code == -54 || e.code == -104 || e.code == -131 || e.code == -232 || e.code == -4077. In the places where those codes mean something else on a different system, it's in situations not related to TCP. Eg code 54 in Generic architecture is EXFULL (exchange full), used in email processing, would never be seen in this situation.

ashleysommer added a commit to ashleysommer/HTTP.jl that referenced this issue Sep 21, 2021
Windows uses -4077
SPAC and ALPHA on linux use -54
Generic on linux uses -104
PARSIC on linux uses -232
MIPS on linux uses -131
I'm guessing MacOS uses -54 too, as this was one code that already worked for a large group of people.
Fixes JuliaWeb#763 JuliaWeb#547
quinnj pushed a commit that referenced this issue Sep 22, 2021
Windows uses -4077
SPAC and ALPHA on linux use -54
Generic on linux uses -104
PARSIC on linux uses -232
MIPS on linux uses -131
I'm guessing MacOS uses -54 too, as this was one code that already worked for a large group of people.
Fixes #763 #547
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant