except socket.error as err:
if isinstance(err.args, tuple):
if err[0] == errno.EPIPE:
# remote peer disconnected
logger.info('IEC104 Station disconnected. (%s)', session.id)
session.add_event({'type': 'CONNECTION_LOST'})
else:
# determine and handle different error
pass
else:
print(("socket error ", err))
we use err[0], buf we determine whether err.args are tuples.
So I got the following error:
Traceback (most recent call last):
File "/home/flyour/.pyenv/versions/3.8.3/lib/python3.8/site-packages/conpot-0.6.0-py3.8.egg/conpot/protocols/melsoft/melsoft_server.py", line 56, in handle
request_data = sock.recv(1024)
File "/home/flyour/.pyenv/versions/3.8.3/lib/python3.8/site-packages/gevent/_socket3.py", line 450, in recv
return self._sock.recv(*args)
ConnectionResetError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
File "/home/flyour/.pyenv/versions/3.8.3/lib/python3.8/site-packages/gevent/baseserver.py", line 34, in _handle_and_close_when_done
return handle(*args_tuple)
File "/home/flyour/.pyenv/versions/3.8.3/lib/python3.8/site-packages/conpot-0.6.0-py3.8.egg/conpot/protocols/melsoft/melsoft_server.py", line 79, in handle
if err[0] == errno.EPIPE:
TypeError: 'ConnectionResetError' object is not subscriptable
2020-06-30T03:48:24Z <Greenlet at 0x7f6f49e197b0: _handle_and_close_when_done(<bound method MelsoftServer.handle of <conpot.prot, <bound method StreamServer.do_close of <StreamServ, (<gevent._socket3.socket [closed] at 0x7f6f49d4e04)> failed with TypeError
https://github.com/mushorg/conpot/blob/ff7e786ecc9d4a015a27147fe4355f5cd7532db9/conpot/protocols/IEC104/IEC104_server.py#L111
we use err[0], buf we determine whether err.args are tuples. So I got the following error: