I am trying the develop a program (in python 3) in which it is possible to transfer a certain amount of data from a computer to another with bluetooth (using pybluez). After a client connects to the device, for some reason, the server side of the application raises a BluetoothError exception after around 30 seconds. It raises the following exception:
bluetooth.btcommon.BluetoothError: (103, 'Software caused connection abort')
I thought that I could be something in my code, so I decided to do a simpler version, in order to test it. I got the exact same error.
The following code is the simpler version I talked about previously.
This is the server side
from bluetooth import *
x = BluetoothSocket(RFCOMM)
print("bind")
x.bind(("", 1))
print("listen")
x.listen(1)
print("accepting")
conn, _ = x.accept()
print("reading")
print(conn.recv(256).decode('utf-8'))
print("closing")
conn.close()
x.close()
This is the client side
from bluetooth import *
x = BluetoothSocket(RFCOMM)
x.connect((<addr>,1))
NOTE: the client side is not executed from a file, but writen directly in the python shell
After putting the server side script running on a regular computer and the client side script on a raspberry pi 3 with raspbian I get the BluetoothError after 30 seconds. The exception is raised on the line:
print(conn.recv(256).decode('utf-8'))
During this time I am able to send messages from one side to another. No matter what I do, after 30 seconds, the exception is raised.
I have no idea of what is happening. I am going to try with another computer with the client script, but it is getting complicated (windows, am I right :p).