socket.close() causes Bad Request in nginx logs #11177
SergeiFranco
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was troubleshooting errant 400 bad requests in nginx logs caused by my micropython socket (not urequests) code.
The error looks like this:
192.168.1.254 - - [02/Apr/2023:12:15:04 +1200] "" 400 0 "-" "-"
The actual request worked fine with 200 OK, then immediately the line above appears in the nginx/access.log
I traced it to socket.close(), it seems that in micropython socket.close() sends EOF, which is a bad request form nginx point of view.
Is there anyway to shutdown the socket without sending EOF (there is no shutdown() method unlike in regular python, at least according to this https://docs.micropython.org/en/latest/library/socket.html) ?
Do I just not close the socket and call gc.collect() which theoretically will release the socket?
Beta Was this translation helpful? Give feedback.
All reactions