BlueDot
BlueDot copied to clipboard
Randomly getting ConnectionAbortedError on receive data and 'Transport endpoint is not connected' on send data errors
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:
- Set-up a
BluetoothAdapter
on both client and server side - Start on server side with
BluetoothServer
and the client with theBluetoothClient
- Have a
data_received_callback
function on both sides waiting for new data to come - On both sides send data with the respective
send
functions. - 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.