micropython / micropython-lib

Core Python libraries ported to MicroPython
Other
2.4k stars 997 forks source link

urequests issue OSError: [Errno 103] ECONNABORTED possible MTU issue #645

Closed h3b4r1 closed 1 year ago

h3b4r1 commented 1 year ago

I've been trying to get a fairly simple requests function working

    @property
    def alm_state(self):
        payload = '[{"cmd":"GetAlarm", "action": 1, "param":{"Alarm": {"type": "md", "channel": 0}}}]'
        return urequests.post(f'http://{self.ip}/api.cgi?cmd=GetAlarm&token={self.api_token}', json=payload).json()

However the issue I think is with the network being unable to respond to lower MTU paths If I do a simple requests to a HTTP endpoint on the LAN everything works as expected, however if I do one to a HTTP endpoint over a VPN I get an error.

urequests.post("http://192.168.4.5")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "urequests.py", line 120, in post
  File "urequests.py", line 60, in request
OSError: [Errno 103] ECONNABORTED

Public websites are mostly ok and local HTTP endpoints are ok.

>>> urequests.post("http://10.16.4.1")
<Response object at 3fff0890>
>>> urequests.post("http://www.cisco.com")
<Response object at 3fff12f0>
>>>

I looked into the network library but there is no option to change MTU. I suspect that the network stack on the NodeMCU boards at least is unable to respond to MTU changes.

h3b4r1 commented 1 year ago

Ok so checked and not an MTU issue, this really has me stumped,