ds4drv icon indicating copy to clipboard operation
ds4drv copied to clipboard

socket.error: [Errno 107] Transport endpoint is not connected (Gentoo)

Open dtony opened this issue 11 years ago • 38 comments

I got this error when trying to run ps4drv on Gentoo. The entire trace is :

ds4drv
[info][controller 1] Created devices /dev/input/js2 (joystick) /dev/input/event10 (evdev) 
[info][bluetooth] Scanning for devices
[info][bluetooth] Found device A4:15:66:6F:3B:A0
Traceback (most recent call last):
  File "/usr/bin/ds4drv", line 9, in <module>
    load_entry_point('ds4drv==0.3.0', 'console_scripts', 'ds4drv')()
  File "/usr/lib64/python2.7/site-packages/ds4drv/__main__.py", line 325, in main
    for device in backend.devices:
  File "/usr/lib64/python2.7/site-packages/ds4drv/backends/bluetooth.py", line 117, in devices
    device = self.find_device()
  File "/usr/lib64/python2.7/site-packages/ds4drv/backends/bluetooth.py", line 106, in find_device
    return BluetoothDS4Device.connect(bdaddr)
  File "/usr/lib64/python2.7/site-packages/ds4drv/backends/bluetooth.py", line 34, in connect
    return cls(addr, ctl_socket, int_socket)
  File "/usr/lib64/python2.7/site-packages/ds4drv/backends/bluetooth.py", line 41, in __init__
    super(BluetoothDS4Device, self).__init__(addr, "bluetooth")
  File "/usr/lib64/python2.7/site-packages/ds4drv/device.py", line 70, in __init__
    self.set_operational()
  File "/usr/lib64/python2.7/site-packages/ds4drv/backends/bluetooth.py", line 66, in set_operational
    self.set_led(255, 255, 255)
  File "/usr/lib64/python2.7/site-packages/ds4drv/device.py", line 82, in set_led
    self._control()
  File "/usr/lib64/python2.7/site-packages/ds4drv/device.py", line 75, in _control
    flash_led2=self._led_flash[1], **kwargs)
  File "/usr/lib64/python2.7/site-packages/ds4drv/device.py", line 130, in control
    self.write_report(report_id, pkt)
  File "/usr/lib64/python2.7/site-packages/ds4drv/backends/bluetooth.py", line 63, in write_report
    self.ctl_sock.sendall(hid + data)
  File "/usr/lib64/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 107] Transport endpoint is not connected

bluez version is 4.101

dtony avatar Feb 12 '14 09:02 dtony

Does this happen everytime you try to connect the controller or only sometimes?

chrippa avatar Feb 12 '14 10:02 chrippa

It happens everytime. If you need any other information tell me.

dtony avatar Feb 12 '14 10:02 dtony

What kernel version, Python version and bluetooth dongle are you using?

chrippa avatar Feb 12 '14 22:02 chrippa

$ uname -a
Linux obelix 3.10.25-gentoo #1 SMP Thu Feb 6 12:33:07 CET 2014 x86_64 AMD FX(tm)-8120 Eight-Core Processor AuthenticAMD GNU/Linux
$ python2.7 --version
Python 2.7.5
$ lsusb
Bus 002 Device 002: ID 0a5c:2101 Broadcom Corp. BCM2045 Bluetooth

The usb dongle is plugged on usb3 socket. I have another dongle, will test with it.

Edit : It work fine with the other dongle :

Bus 002 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

Is there a need for bluetooth 4.0, because it work under windows with both dongles.

dtony avatar Feb 13 '14 10:02 dtony

Exactly the same error here. Some news?

petretRaf avatar Feb 13 '14 13:02 petretRaf

Is there a need for bluetooth 4.0, because it work under windows with both dongles.

Well, what seems to be happening is that the connection to the device is instantly dropped. I have no idea why though, it could be due to incomplete or bad driver for your dongle in bluez.

You could try pairing it in bluez first (requires bluez 5.14) and then run ds4drv in hidraw mode (ds4drv --hidraw).

Exactly the same error here. Some news?

What bluetooth dongle, bluez version and kernel do you use?

chrippa avatar Feb 13 '14 14:02 chrippa

$ uname -a Linux laptop 3.11.0-15-generic #25-Ubuntu SMP Thu Jan 30 17:22:01 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux $ python --version Python 2.7.5+ $ lsusb Bus 001 Device 020: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

bluez 5.14

petretRaf avatar Feb 13 '14 15:02 petretRaf

bluez 5.14

Since you use bluez 5.14, does pairing it normally work?

chrippa avatar Feb 13 '14 16:02 chrippa

$ bluetoothctl [bluetooth]# version Version 5.14

And now for pairing normally how should i do? [bluetooth]# pair + MAC?

edit: I get this : Device not available

petretRaf avatar Feb 13 '14 16:02 petretRaf

And now for pairing normally how should i do?

$ bluetoothctl -a
[bluetooth]# scan on
[bluetooth]# trust MAC
[bluetooth]# pair MAC

chrippa avatar Feb 13 '14 16:02 chrippa

[bluetooth]# scan on No default controller available

petretRaf avatar Feb 13 '14 16:02 petretRaf

No default controller available

Try this:

[bluetooth]# show
[bluetooth]# select <MAC of bluetooth dongle>

chrippa avatar Feb 13 '14 16:02 chrippa

[bluetooth]# show No default controller available

How can i set a default controller?

petretRaf avatar Feb 13 '14 17:02 petretRaf

[bluetooth]# show No default controller available

Ah, my bad, seems like I gave you wrong command, this is the correct command to show your controllers: [bluetooth]# list Then do [bluetooth]# select <MAC of bluetooth dongle> to set the default controller.

chrippa avatar Feb 13 '14 17:02 chrippa

[bluetooth]# list [bluetooth]# select 60:6c:66:5b:f9:c2 Controller 60:6c:66:5b:f9:c2 not available

List shows me nothing, and even with the MAC of my bluetooth dongle it doesn't set the default controller. I don't understand..

edit : I tried with 2 bluetooth dongles, 1 on USB, and 1 of my laptop

petretRaf avatar Feb 13 '14 17:02 petretRaf

That's odd, what is the output of hciconfig?

chrippa avatar Feb 13 '14 17:02 chrippa

$ hciconfig hci0: Type: BR/EDR Bus: USB BD Address: 00:15:83:0C:BF:EB ACL MTU: 339:8 SCO MTU: 128:2 UP RUNNING PSCAN RX bytes:555 acl:0 sco:0 events:32 errors:0 TX bytes:385 acl:0 sco:0 commands:26 errors:0

and with my other dongle :

hci0: Type: BR/EDR Bus: USB BD Address: 60:6C:66:5B:F9:C2 ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING PSCAN RX bytes:589 acl:0 sco:0 events:34 errors:0 TX bytes:898 acl:0 sco:0 commands:33 errors:0

petretRaf avatar Feb 13 '14 17:02 petretRaf

Got no clue what could be wrong, I guess you could try a different bluetooth tool like gnome-bluetooth to do the pairing.

chrippa avatar Feb 13 '14 20:02 chrippa

When i started ./configure for bluez 5.14, i get this error : checking systemd system unit dir... configure: error: systemd system unit directory is required So i had to launch ./configure --disable-systemd but the dbus daemon which is started automatically by systemd, is used to read settings and for PIN pairing. Do you think it could be my problem?

petretRaf avatar Feb 14 '14 12:02 petretRaf

Yes, if bluetoothd is not running it's probably not possible to pair. Perhaps you should check if there is a package available for your distro instead of building manually to make sure things are correctly setup on your system. If not, check if there is a init script in /etc/init.d/ to start the daemon.

chrippa avatar Feb 14 '14 12:02 chrippa

I just experienced the "Transport endpoint is not connected" error. I have 2 dongles. The first one works fine and it's a bluetooth 4.0 usb dongle. The second one gives me the transport error and it's a bluetooth 2.0 usb dongle.

The fact is that standard pairing is also problematic because it asks for a PIN, which does not happen to be necessary with the other device.

I managed to pair it using bluetoothctl after enabling the agent:

[bluetooth]# scan on
[bluetooth]# trust MAC
[bluetooth]# agent on
[bluetooth]# pair MAC
Request PIN code
[agent] Enter PIN code: 0000

And then "ds4drv --hidraw" worked fine.

Recap:

  • Without the "agent on" command, pair fails with "Failed to pair: org.bluez.Error.AuthenticationRejected" with the bluetooth 2 dongle.
  • The agent/pin steps are not necessary with the bluetooth 4 dongle.

mtorromeo avatar Feb 14 '14 13:02 mtorromeo

I tried pairing my DS4 with bluez-simple-agent hci0 MAC, but i get this error : Creating device failed: org.bluez.Error.ConnectionAttemptFailed: Page Timeout.

petretRaf avatar Feb 14 '14 14:02 petretRaf

I was using bluez 5.14, I don't know about bluez 4

mtorromeo avatar Feb 14 '14 16:02 mtorromeo

I've pushed f3db91b53f3d8593a8de6de2a3297d60fe700009 which will make sure we don't crash when this happens, and will attempt to retry the connection. I don't think that will help much though, since it seems like our way of connecting directly to the DS4 without pairing only works on some dongles.

For the record, the bluetooth dongle I'm using is built into my motherboard (Asus P8Z68-V) and is v2.1. It seems like 2.0 dongles have issues, but might work if paired in bluez 5.14 as @mtorromeo describes.

chrippa avatar Feb 14 '14 17:02 chrippa

It's now working!!! Thanks, i don't know why i can't do the pairing/connection with bluetoothctl, but with this last commit i don't have the socket.error anymore!

edit: after starting ds4drv a second time, i get the socket.error again ... T_T

petretRaf avatar Feb 14 '14 17:02 petretRaf

I've got this error a few times now as well. I'm on Ubuntu 13.10 x64 with bluez 4 and using a broadcom BCM2046B1 2.0 dongle. I'm running the driver in raw bluetooth mode and everything works fine. While I haven't figured out a way to reliably reproduce it I did find a way to get past the error by running blueman (bluetooth-manager) and deleting the wireless controller from the devices list. After that I can connect as usual. My laptop also has built-in bluetooth and a couple times I've seen the controller show up in the device list for the internal bluetooth as well. Again deleting it from the list of devices and trying to reconnect always results in success.

nr1971 avatar Feb 15 '14 20:02 nr1971

Again deleting it from the list of devices and trying to reconnect always results in success.

Sounds like bluetoothd might be interfering somehow, try killing it and see if it helps.

chrippa avatar Feb 15 '14 21:02 chrippa

I've solved this error, at least on Arch Linux ARM (running on a Raspberry Pi). I had to restart the bluetooth service, then go into bluetoothctl and power on the device. Commands are below.

systemctl restart bluetooth
systemctl enable bluetooth
bluetoothctl
power on
exit
ds4drv

bluejorts avatar Mar 04 '14 09:03 bluejorts

I also have this issue. Following the instructions here i got it work on Linux Mint 17 using the command

bluez-simple-agent hci0 <my ds4 mac> remove

it prints out Creating device failed: org.bluez.Error.ConnectionAttemptFailed: Page Timeout but it still works

bakkerthehacker avatar Mar 06 '15 19:03 bakkerthehacker

Suddenly this problem started to occur for me. I fixed this with bluetoothctl and "remove MAC".

Ape avatar Jul 12 '15 07:07 Ape