BlueDot icon indicating copy to clipboard operation
BlueDot copied to clipboard

Randomly getting ConnectionAbortedError on receive data and 'Transport endpoint is not connected' on send data errors

Open wallem89 opened this issue 1 year ago • 1 comments

Describe the bug I am running this software on two Raspberry Pi's and one is the server an the other Pi is the client. Both are used to send and receive data. I am getting both issues randomly at the client side. Both programs are quite identical since both are waiting for new data to come in with the data_received_callback and both are sending data with the send function. But the server with the send function from BluetoothServer and the client from BluetoothClient.

ConnectionAbortedError in receive thread:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.7/site-packages/bluedot/btcomm.py", line 716, in _read
    self._handle_bt_error(e)
  File "/usr/local/lib/python3.7/site-packages/bluedot/btcomm.py", line 746, in _handle_bt_error
    raise bt_error
  File "/usr/local/lib/python3.7/site-packages/bluedot/btcomm.py", line 714, in _read
    data = self._client_sock.recv(1024, socket.MSG_DONTWAIT)
ConnectionAbortedError: [Errno 103] Software caused connection abort

Transport endpoint is not connected error during sending:

ERROR:grpc._server:Exception calling application: [Errno 107] Transport endpoint is not connected
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/grpc/_server.py", line 494, in _call_behavior
    response_or_iterator = behavior(argument, context)
  File "./client.py", line 127, in send
    self.client.send(data)
  File "/usr/local/lib/python3.7/site-packages/bluedot/btcomm.py", line 698, in send
    self._handle_bt_error(e)
  File "/usr/local/lib/python3.7/site-packages/bluedot/btcomm.py", line 746, in _handle_bt_error
    raise bt_error
  File "/usr/local/lib/python3.7/site-packages/bluedot/btcomm.py", line 696, in send
    self._send_data(data)
  File "/usr/local/lib/python3.7/site-packages/bluedot/btcomm.py", line 707, in _send_data
    self._client_sock.sendall(data)
OSError: [Errno 107] Transport endpoint is not connected

To Reproduce Steps to reproduce the behavior:

  1. Set-up a BluetoothAdapter on both client and server side
  2. Start on server side with BluetoothServer and the client with the BluetoothClient
  3. Have a data_received_callback function on both sides waiting for new data to come
  4. On both sides send data with the respective send functions.
  5. Wait.. (time various)

Expected behavior A reliable connection that even when the bluetooth connection disconnects or the other side is outside range the program doesn't crash. I want a clear error message and be able to connect the client to the server after they have disconnected.

System (please complete the following information):

  • OS: Balena OS (raspberrypi4-64-debian-python)
  • Version: 3.7-buster

Additional context Both programs using the build-in Bluetooth adapter of the Raspberry Pi 4.

wallem89 avatar May 08 '23 06:05 wallem89