urequests error
Posted: Sat Jul 30, 2016 7:12 am
I am using latest urequests from micropython-lib.
In some rare cases (once in few hours for requests performed repeatedly every second) I get empty response without any header:
{"AirTemperature":23, "FanRpm":0, "MemoryFree":36960, "MemoryAllocated":20656, "DeviceStartup":false, "Error":null}
b'HTTP/1.1 200 OK\r\n'
{"AirTemperature":23, "FanRpm":0, "MemoryFree":36960, "MemoryAllocated":20656, "DeviceStartup":false, "Error":null}
b'HTTP/1.1 200 OK\r\n'
{"AirTemperature":23, "FanRpm":0, "MemoryFree":36960, "MemoryAllocated":20656, "DeviceStartup":false, "Error":null}
b''
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "main.py", line 294, in reportStatus
File "main.py", line 283, in reportStatus
File "/flash/lib/urequests.py", line 108, in put
File "/flash/lib/urequests.py", line 78, in request
ValueError: wrong number of values to unpack
>>>
This empty response obviously causes failure of following line from urequests.py:
protover, status, msg = l.split(None, 2)
The server was tested for several days with another client and there was no case of empty response therefore I started suspect my client side (WiPy MicroPython).
Do you have any idea what could cause that there is no response to be read from the socket?
In some rare cases (once in few hours for requests performed repeatedly every second) I get empty response without any header:
{"AirTemperature":23, "FanRpm":0, "MemoryFree":36960, "MemoryAllocated":20656, "DeviceStartup":false, "Error":null}
b'HTTP/1.1 200 OK\r\n'
{"AirTemperature":23, "FanRpm":0, "MemoryFree":36960, "MemoryAllocated":20656, "DeviceStartup":false, "Error":null}
b'HTTP/1.1 200 OK\r\n'
{"AirTemperature":23, "FanRpm":0, "MemoryFree":36960, "MemoryAllocated":20656, "DeviceStartup":false, "Error":null}
b''
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "main.py", line 294, in reportStatus
File "main.py", line 283, in reportStatus
File "/flash/lib/urequests.py", line 108, in put
File "/flash/lib/urequests.py", line 78, in request
ValueError: wrong number of values to unpack
>>>
This empty response obviously causes failure of following line from urequests.py:
protover, status, msg = l.split(None, 2)
The server was tested for several days with another client and there was no case of empty response therefore I started suspect my client side (WiPy MicroPython).
Do you have any idea what could cause that there is no response to be read from the socket?