-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
TCP not closing properly after POST #3208
Comments
I assume that the issue might be within HTTP parser in C from nodejs that we use. |
I just tried python 3.7... didn't help. Will do as you suggest Edit: |
Oh, just make sure that you do Also, you could try running your aiohttp app with |
Tried AIOHTTP_NO_EXTENSIONS=1 , that had the same issue. Is that enough to prove it? |
Yeah, it should be enough. You could share asciinema recording of how you run it if you're unsure that you do it right :) |
Hm.. I think you might need to This'll do:
(it affects only source dists as wheels come with extensions pre-compiled) |
Ahh... yes that worked, the bug doesn't show up so.... now what? Also I did try compiling the package with Is there some way to force aiohttp to not use the extensions from my package? Otherwise I'll have to just use normal requests and probably do it in a thread so it doesn't block waiting on IO, which is disappointing. |
Well, using that Also, after re-reading your issue description I realized that the difference you're seeing might be HTTP pipelining. Could you confirm whether your tests use HTTP/1.0 or HTTP/1.1 with or without pipelining? |
May I also ask you to extract and post plain text HTTP request-responses? |
The HTTP is exactly the same / normal:
It's the TCP layer that doesn't seem to work properly. Here's a screen cap of the wireshark capture. The first packet exchange is the older version of aiohttp, which works fine (up to the first blue packet, which is an unrelated UDP packet) The second bit is with the latest aiohttp. It seems not to send the Maybe the sequence number for packet 20 actually is the problem? In the first exchange the ack is for seq 206, while in the second it's for 205. I don't really know not a TCP expert unfortunately! Eventually the TCP packet exchange ends: I can't really do an atypical install of aiohttp since this is a library that is then used to integrate with home assistant, so I can't really commit buggy code out into the wild. Maybe I can do something with For debugging purposes, I can port-forward the port through my router if you really need. Maybe try it with a post to something else first though. |
Okay, I can see why you think that it's a TCP level problem. It looks like you're right. Just to record my observations:
Almost: https://stackoverflow.com/a/13050021/595220. It's I won't send you anything but will consume new data from you. So after FIN socket in a client is closed for writing, but still open for reading.
It looks related. In the first case, seq matches the ack from tcp win update, but in the second it doesn't (183 != 205).
I'd like to invite you to get back to bisecting what went wrong with HTTP-parser.
ClientSession already closes it: https://github.com/aio-libs/aiohttp/blob/master/aiohttp/client.py#L828. |
It might be closing it, but it's not actually closing the TCP connection. 10.0.0.66 is the local host here, in the first bit before the blue line FIN gets sent, but in the one where there's a problem it doesn't. I'll see what I can do to further figure it out, but it seems to me like whatever aiohttp is doing isn't working. |
It's probably a bug in http-parser, not aiohttp's own code. That's why I want to find out the problem there by bisecting it. |
Actually this goes on for a heap of packets, not just those three. If you see the second screencap it goes through to packet 4886
First server's FIN didn't get lost, it just didn't get sent.
Yes, well I can agree with that. Is http-parser going to be amenable to being fixed however? |
It's here: https://github.com/nodejs/http-parser. And there's actually 9 new commits since the last sync, so we'll need to grab updates as well. cc @asvetlov @Swamp-Ig could you please try upgrading the submodule with http-parser and do the test after rebuilding aiohttp? |
I've upgraded http-parser in master (#3209) |
OK... interesting. I compiled and installed under python 3.6.6 in windows subsystem for unix with debian. It did take a bit of messing about because I had to install python 3.6.6. This seemed to fix the problem. However rolling back to aiohttp v3.3.2 did have the problem. I don't know what's changed, but whatever it is it's fixed it. So I guess you can mark this as fixed on the next release. Will need to get home assistant to update to the new version once it's out of alpha. |
Well. Let's close it |
@asvetlov This all lead me to one idea 💡. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
Long story short
I'm connecting to an IOT device (airconditioner) with a REST interface.
Posting commands using >=3.0 doesn't work. The post goes through and the status OK is returned, but there's some issue with the TCP connection.
Steps to reproduce
Within the wireshark packet capture there's two different TCP transactions with exactly the same aiohttp code running (also within the zip file). The short version of the code without imports etc looks like this:
If you get aiohttp<3.0 you get the first packet capture, up until packet 10. Everything is happy.
With the latest version and any version above 3.0, all goes well until the ACK gets sent for the OK packet, then a whole spume of out of order and dup ack packets goes back and forth.
I can't actually see any difference in what gets sent or anything. It's possible it's the device that's the issue, I've emailed the guys that produce the device so they are on this issue too, but the low level TCP stuff is a bit beyond me.
The odd thing is that http GET works just fine.
Environment
The text was updated successfully, but these errors were encountered: