hologram-io / hologram-python

Hologram device-side Python SDK - Send messages to the cloud in just 3 lines of code!
https://hologram.io/
MIT License
89 stars 47 forks source link

Error in send message code when socket is closed shortly after opening #23

Closed DomAmato closed 4 years ago

DomAmato commented 4 years ago

Describe the problem

2020-03-17 21:10:02,755 [DEBUG] Hologram.Network.Modem.IModem (7665): [AT+USOCR=6]
2020-03-17 21:10:03,758 [DEBUG] Hologram.Network.Modem.IModem (7665): [AT+USOCO=0,"cloudsocket.hologram.io",9999]
2020-03-17 21:10:21,568 [DEBUG] Hologram.Network.Modem.IModem (7665): {}
2020-03-17 21:10:21,571 [DEBUG] Hologram.Network.Modem.IModem (7665): {+USOCR: 0}
2020-03-17 21:10:21,572 [DEBUG] Hologram.Network.Modem.IModem (7665): URC! +USOCR: 0
2020-03-17 21:10:21,572 [DEBUG] Hologram.Network.Modem.IModem (7665): handleURC state: 0
2020-03-17 21:10:21,573 [DEBUG] Hologram.Network.Modem.IModem (7665): URC was not handled. '+USOCR: 0'
2020-03-17 21:10:21,574 [DEBUG] Hologram.Network.Modem.IModem (7665): {}
2020-03-17 21:10:21,575 [DEBUG] Hologram.Network.Modem.IModem (7665): {OK}
2020-03-17 21:10:21,575 [INFO] Hologram.Network.Modem.IModem (7665): Connect socket is successful
2020-03-17 21:10:23,578 [INFO] Hologram.Cloud (7665): Sending message with body of length 1071
2020-03-17 21:10:23,582 [DEBUG] Hologram.Network.Modem.IModem (7665): [AT+UDCONF=1,1]
2020-03-17 21:10:23,584 [DEBUG] Hologram.Network.Modem.IModem (7665): {+UUSOCL: 0}
2020-03-17 21:10:23,584 [DEBUG] Hologram.Network.Modem.IModem (7665): URC! +UUSOCL: 0
2020-03-17 21:10:23,585 [DEBUG] Hologram.Network.Modem.IModem (7665): handleURC state: 0
2020-03-17 21:10:23,587 [DEBUG] Hologram.Network.Modem.IModem (7665): {}
2020-03-17 21:10:23,588 [DEBUG] Hologram.Network.Modem.IModem (7665): {OK}
2020-03-17 21:10:23,591 [DEBUG] Hologram.Network.Modem.IModem (7665): [AT+USOWR=b'0,255,"hex encoded data"']
2020-03-17 21:10:23,602 [DEBUG] Hologram.Network.Modem.IModem (7665): {}
2020-03-17 21:10:23,607 [DEBUG] Hologram.Network.Modem.IModem (7665): {+CME ERROR: operation not allowed}
2020-03-17 21:10:23,607 [ERROR] Hologram.Network.Modem.IModem (7665): Failed to write to socket

Expected behavior

The operation should fail gracefully but it looks to keep trying to send the message indefinitely

Actual behavior

It gets into a loop of trying to send the message in what appears to be an endless loop

Steps to reproduce the behavior

Current device in the office always falls into this behavior

System information

DomAmato commented 4 years ago

so more investigation into how this is handled shows that it is acting properly. The issue of the socket closing during a write is not something the SDK as its currently written is able to handle as the URC message is handled but does not interrupt write to the modem (as it shouldn't) closing as wont fix