Skip to content

Brokenpipe issue when using TCP connection #765

@alligitor

Description

@alligitor

I'm using the python API to talk to a Meshtastic instance running on localhost. this is a Raspberry Pi 3B, if that matters.

Every so often, it gets the following error:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.11/threading.py", line 1394, in run
    self.function(*self.args, **self.kwargs)
  File "/home/pi/meshtastic/lib/python3.11/site-packages/meshtastic/mesh_interface.py", line 1116, in callback
    self.sendHeartbeat()
  File "/home/pi/meshtastic/lib/python3.11/site-packages/meshtastic/mesh_interface.py", line 1105, in sendHeartbeat
    self._sendToRadio(p)
  File "/home/pi/meshtastic/lib/python3.11/site-packages/meshtastic/mesh_interface.py", line 1180, in _sendToRadio
    self._sendToRadioImpl(toRadio)
  File "/home/pi/meshtastic/lib/python3.11/site-packages/meshtastic/stream_interface.py", line 120, in _sendToRadioImpl
    self._writeBytes(header + b)
  File "/home/pi/meshtastic/lib/python3.11/site-packages/meshtastic/tcp_interface.py", line 79, in _writeBytes
    self.socket.send(b)
BrokenPipeError: [Errno 32] Broken pipe

I saw the following article and tried the meshtastic.connection.lost, but that does not get called when this error happens.

#727

using try/except doesn't help because the error happens in a thread that the Meshtastic python lib kicks off.

the following property, doesn't change either when this error happens:
interface.isConnected

Looking at the python code, I don't see any error handling for when _writeBytes fails.

Any thoughts on how best to handle this error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions