21

I installed Unified Remote today in hope that I can use it with my bluetooth adapter to control my PC using my phone. But as I installed Unified Remote and loaded up the web interface, I got this error:

Bluetooth: Could not connect to SDP

Google has absoluetly nothing helpful about this error so this is one of my only chances here.

some outputs:

noneatme@noneatme-desktop:/etc/bluetooth$ sudo sdptool browse local
Failed to connect to SDP server on FF:FF:FF:00:00:00: Connection refused

Ubuntu 16.04

noneatme@noneatme-desktop:/etc/bluetooth$ uname -a
Linux noneatme-desktop 4.4.0-22-generic #40-Ubuntu SMP Thu May 12 22:03:46 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

noneatme@noneatme-desktop:/etc/bluetooth$ /usr/lib/bluetooth/bluetoothd -C
D-Bus setup failed: Connection ":1.129" is not allowed to own the service "org.bluez" due to security policies in the configuration file
(it works with sudo)

Starting Bluetoothd with --compat argument won't fix the problem.

What can I do?

/edit: I fixed this problem by starting the unified remote server as sudo. Is this really the only option I have?

4 Answers 4

35

You need to run the bluetooth daemon in compatibility mode to provide deprecated command line interfaces. You're running Bluez5 and you need some Bluez4 functions. You can do this by editing this file

/etc/systemd/system/dbus-org.bluez.service and changing this line

ExecStart=/usr/lib/bluetooth/bluetoothd to this

ExecStart=/usr/lib/bluetooth/bluetoothd --compat

and then restarting bluetooth like this

sudo systemctl daemon-reload
sudo systemctl restart bluetooth

and you'll also have to change permissions on /var/run/sdp

sudo chmod 777 /var/run/sdp

and finally restart unified remote server

5
  • Thank you for your help. Can you also let me know how would you make the permission permanent? At the moment when restarting my pc, the permission is lost. Thanks
    – Adrian
    Jun 28, 2017 at 8:32
  • Sorry to bump, I also want to know how to make the permission permanent because I am running into the same issue. The above fix worked but I want to make it automatic whenever I boot. May 10, 2018 at 19:49
  • I am on debian and I do not have this file =/ Dec 4, 2019 at 1:19
  • in 2021 this fix worked briefly then stopped working. Did something change?
    – Phlip
    Feb 18, 2021 at 1:04
  • This works but blocks my headset to connect to the same bluetooth. (It connects, but doesn't appear in sound devices.)
    – Binyomin
    Nov 15, 2023 at 9:56
7

Another solution:

Edit /etc/systemd/system/dbus-org.bluez.service:

ExecStart=/usr/lib/bluetooth/bluetoothd --compat
ExecStartPost=/bin/chmod 777 /var/run/sdp

Because permissions of /var/run/sdp seems to reset on every reboot.

1
  • I am on debian and I do not have this file =/ Dec 4, 2019 at 1:19
1

I managed to get it working by creating a new systemd service.

  1. Create a config file named /etc/systemd/system/urserver.service with contents of:

    [Unit]
    Description=Unified Remote Server
    After=syslog.target network.target
    
    [Service]
    Environment="HOME=/opt/urserver"
    Type=forking
    PIDFile=/opt/urserver/.urserver/urserver.pid
    ExecStartPre=/bin/chmod 777 /var/run/sdp
    ExecStart=/opt/urserver/urserver-start --no-manager --no-notify
    ExecStop=/opt/urserver/urserver-stop
    
    RemainAfterExit=no
    Restart=on-failure
    RestartSec=5s
    
    [Install]
    WantedBy=default.target
    
  2. Set the permissions on the file:

    sudo chmod a+x /etc/systemd/system/urserver.service
    
  3. Reload systemd daemon:

    sudo systemctl daemon-reload
    
  4. Start the actual service:

    sudo systemctl start urserver
    

You should disable "Automatically start server when OS starts up." from Unified Remote Settings (web interface), because systemd will start the service automatically. systemd will also restart service if it crashes for some reason.

Edited: Environment and PIDFile, thanks to Niklas

4
  • I'd like to suggest an improvement to the above configuration. urserver-start now runs as root and attempts to create the pidfile, .config directory and .remotes directory in the system root. If you set it to run as another user then modifying the permissions on /var/run/sdp fails. What I did was to change the environment for urserver-start by adding Environment="HOME=/opt/urserver"and changing PIDFile=/opt/urserver/.urserver/urserver.pid under [Service]. Now it starts without errors and stray or missing directories.
    – Niklas
    Aug 11, 2018 at 9:52
  • This answer, together with adding --compat for the bluetooth service, should really be the accepted answer since it's a persistent solution across multiple reboots.
    – Niklas
    Aug 11, 2018 at 9:53
  • Execute permissions should not be needed on systemd service files, as they are no scripts. Please remove the chmod. May 2, 2019 at 5:52
  • To enable automatic start on boot systemctl enable urserver.service may be run. May 2, 2019 at 5:54
0

I combined the other answers to get this working and make it persist through reboots. Here is a step-by-step guide to get it working:

Uncheck the "Automatically start server when OS starts up." box in the Unified Remote settings GUI.

Stop urserver. You can do this with:

    user@machine:~$ sudo killall urserver

Next as Leo Pedraza said edit /etc/systemd/system/dbus-org.bluez.service and change this line

    ExecStart=/usr/lib/bluetooth/bluetoothd 

to this

    ExecStart=/usr/lib/bluetooth/bluetoothd --compat

Then do as Esa Nikulainen and Niklas suggested and create a new systemd service like so:

Create a config file named /etc/systemd/system/urserver.service with contents of:

    [Unit]
    Description=Unified Remote Server
    After=syslog.target network.target

    [Service]
    Environment="HOME=/opt/urserver"
    Type=forking
    PIDFile=/opt/urserver/.urserver/urserver.pid
    ExecStartPre=/bin/chmod 777 /var/run/sdp
    ExecStart=/opt/urserver/urserver-start --no-manager --no-notify
    ExecStop=/opt/urserver/urserver-stop

    RemainAfterExit=no
    Restart=on-failure
    RestartSec=5s

    [Install]
    WantedBy=default.target

Reload systemd daemon:

    user@machine:~$ sudo systemctl daemon-reload

Restart bluetooth like this:

    user@machine:~$ sudo systemctl restart bluetooth

Start the new service:

    user@machine:~$ sudo systemctl start urserver

Enable the new service so it runs at startup:

    user@machine:~$ sudo systemctl enable urserver

THANK YOU Leo Pedraza, Esa Nikulainen, and Niklas for figuring out all the pieces!

3
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review May 1, 2019 at 19:41
  • I changed my post to provide an actual answer that combines the other answers into a more comprehensive step-by-step guide. May 1, 2019 at 21:33
  • Having execute permissions should not be needed on a systemd service. I'd suggest removing the chmod. May 2, 2019 at 5:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .