-
Notifications
You must be signed in to change notification settings - Fork 13
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
Edge case uncaught exception in fjagepy send #321
Comments
Thanks @impala454. Let me take a look at this. |
Here's a sample where I was able to reproduce this most of the time. Steps:
The script: #!/usr/bin/env python3
from time import sleep
from fjagepy import Gateway
from unetpy import TxFrameReq
modem_ip_address = "192.168.10.38"
modem_port = 1100
remote_modem_addr = 58
gateway = None
transport = None
reconnect = True
counter = 0
while True:
if not gateway:
reconnect = True
elif not gateway.isConnected():
print('disconnected')
reconnect = True
if reconnect:
try:
print('connecting')
gateway = Gateway(hostname=modem_ip_address, port=modem_port)
except Exception as ex:
print(f'connect failed: {ex}')
sleep(0.1)
continue
else:
transport = gateway.agent('transport')
reconnect = False
print('connected')
req = TxFrameReq()
req.type = 2
req.to = remote_modem_addr
req.data = list(bytearray('\x00\x23\x04\x54\x65\x13\x05\x36\x76\x31\x12\x13\x07', encoding='utf-8'))
print(f'sending {counter}')
try:
transport.send(req)
except Exception as ex:
print(f'lockup.py exception {counter}: {ex}')
gateway.close()
counter += 1
else:
print(f'sent {counter}')
counter += 1
sleep(0.1) The main concerns here are two things:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We encountered an issue with fjagepy where, when sending a message via transport. We think this happened when the modem was disconnected during a send operation and the offending line is here. Trace looked like this:
Looking at that code it appears it's using the standard Python socket.sendall() which says it will raise an Exception on error and return
None
on success. So perhaps a check here would be good before returningTrue
so the user doesn't need to catch the underlying socket exceptions.The text was updated successfully, but these errors were encountered: