Соединение невозможно или разорвано protocol not available

Обновлено: 07.07.2024

I'm trying to add a BlueParrott B-250XT+ bluetooth headset on a Thinkpad X230 tablet running Ubuntu 16.04 with its hardware bluetooth adapter.

The adapter works - meaning it detects/sees the headset. However, when connecting to the headset it initially connects, then this error pops up:

Afterwards, the Headset disconnects and future connections are impossible - this is some sort of failure/error that causes the bluetooth to be unresponsive afterwards.

I have Pulseaudio installed and I have bluetooth set to load after X11 (this is what got me this far - to the point I can connect). But, as mentioned, the device gets dumped shortly after connection.

I have two pi's, and I'm trying to send audio from one to the other. I want to sort it out all via console so I can automate things. Let's call the one I'm trying to get the sound from SourcePi and the one I'm trying to send output to SpeakerPi .

I start by setting up SpeakerPi , after some wrangling it all works (including adding profile=a2dp-sink in the service file). I can connect my Android device via bluetooth to SpeakerPi and the sound comes out as expected. Great!

I go to set up SourcePi but I'm having problems. I've been to so many web pages (like this and this - I deactivated onboard audio entirely as it suggested) to try and find the answer to my problem, but no success.

I've change my /lib/systemd/system/bluealsa.service file to read this on SourcePi :

So it should have the a2dp-source available.

However when I connect the two devices via bluetoothctl , I run sudo systemctl status bluetooth.service and see the following lines, the last of which is in bold and red.

I can use aplay to successfully send sound from SourcePi to SpeakerPi , by running this:

aplay -D bluealsa:DEV=AB:CD:EF:01:02:03,PROFILE=a2dp sound/test.mp3

The sound comes out of SpeakerPi as I would want. However what I want is all audio from SourcePi to be sent to SpeakerPi . I think the reason why that's not working is the Protocol not available message above.

I've tried all sorts of restarting the services, minor tweaks, rebooting but to no avail.

The only potential fixes I've found refer to enabling pulseaudio but my impression from all the reading I've done is that alsa is the better way to do things & it's best to leave pulseaudio out.

The text was updated successfully, but these errors were encountered:

borine commented Jan 2, 2021

all the reading I've done is that alsa is the better way to do things & it's best to leave pulseaudio out.

Well, that depends. pulseaudio is a general-purpose sound server, bluealsa provides a bluetooth-specific ALSA plugin. So, for example with desktops or multi-function systems, pulseaudio is generally the way to go. For dedicated sound servers, particularly embedded systems and small boards such as the Pi, bluealsa is best, IMHO. But you need to be clear that bluealsa is only the bluetooth audio interface - for everything else like mixing and monitoring of PCM streams you will need some application that does those things for you.

So, do you need multiple applications accessing the same bluetooth device at the same time? If so, save yourself a lot of pain and go with pulseaudio. If one application at a time is all you need, go with bluealsa.

what I want is all audio from SourcePi to be sent to SpeakerPi

Sounds like you are using multiple applications? Remember with ALSA that each application opens its own connection directly with the device. So each application needs to be told which device to use. If not told which device, then the application will look for a definition of "default" in the ALSA config and connect to that. You can redefine "default" to use a bluealsa device if you are sure that you only ever want to connect to that one device.

graham8 commented Jan 2, 2021

You don't say which OS you are running, but here's my 2d. I have successfully sent BT audio to/from devices (including Pi) running OSMC (Debian derivative). I can start both devices with both source and sink profiles. BT decides which device is source and which sink depending on which device initiates the connection.

Apart from that, you need to check your .asoundrc as @Arkq says.

reedstonefood commented Jan 2, 2021

Thanks for the responses everyone! 👍 A few quick answers for now without booting up my Pi again.

However what I want is all audio from SourcePi to be sent to SpeakerPi.

Hmm, I'm not sure what do you mean by that.

I want what the poster on this link achieved - all audio from Raspbian sent to a bluetooth speaker - in my case the "bluetooth speaker" is SpeakerPi. The poster appears to have managed it using a mixture of the raspbian GUI & bluetoothctl.

Interestingly, when I try the "GUI" way I can't get it to work. I can connect from SourcePi to SpeakerPi, but SpeakerPi does not show up as an audio device which is what the Raspbian instructions suggest.

You don't say which OS you are running

Sorry, it's Raspbian (or Raspberry Pi OS as it's called now)

So, do you need multiple applications accessing the same bluetooth device at the same time? If so, save yourself a lot of pain and go with pulseaudio. If one application at a time is all you need, go with bluealsa.

I imagine most, if not all of the output will be from Chromium. But ideally I wouldn't be limited to that.

I naïvely assumed that, just as my phone could send all its audio to SpeakerPi, that SourcePi would be able to do likewise. If I need to use pulseaudio, could I just use that on SourcePi and leave SpeakerPi with the current bluealsa setup?

I found that file would disappear upon reboot. Couldn't figure it out. So I read some docs and put it in /etc/asound.conf instead, and it does seem to use that file, as I can now leave out the MAC address of SpeakerPi, ie aplay -D sound/test.mp3 successfully outputs the audio. No idea why that is. 🤷‍♂️

I'll look at @Arkq 's suggestion for that file tomorrow & if that doesn't work I'll post the contents of my asound.conf file here.

graham8 commented Jan 2, 2021

Glad you're making progress, but I thought RaspberryPiOS has abandoned bluez-alsa for pulseaudio. Although the announcement implied they were abandoning alsa itself which can't be true so I'm not sure what's going on there.

Haven't tried the latest RaspberryPiOS yet.

borine commented Jan 3, 2021

The RaspberryPiOS full install is a desktop distribution, and has just started using pulseaudio for good reason. That is nothing to do with bluetooth, but everything to do with integrated audio services, such as mixing, sharing, routing and re-routing PCM streams while applications are still running, and a centralized control panel to manage it all. It just happens that pulseaudio also provides a bluetooth interface, so bluealsa is no longer required there.

If you are building a server with no desktop, eg a headless audio server, then bluealsa is the most efficient way to obtain bluetooth audio. Use the RaspberryPiOS Lite image for that. If you are building a user desktop machine, then use pulseaudio - the RaspberryPiOS full image is good for that.

As for files disappearing etc, the older Raspbian images from the RPi foundation used a number of clumsy tricks to try to compensate for the lack of an audio server. Maybe some of those are still there on the new image and now doing more harm than good. When pulseaudio is properly configured then it takes over all ALSA management and users and applications should just use the pulse API and utilities - do not use .asoundrc, /etc/asound.conf and such with pulseaudio. Web posts that suggest such things were all written before raspios adopted pulseaudio for its desktop.

If you are building a user desktop machine, then use pulseaudio - the RaspberryPiOS full image is good for that.

I think I'd rather do this. But, would I be right in saying SpeakerPi should be fine using bluealsa?

On SourcePi I've ran sudo apt-get install pulseaudio-module-bluetooth . This also uninstalls bluealsa . I'm not sure really where to go from here? The GUI way still doesn't work as it still doesn't show up as a sound device.

When I select a bluetooth device to connect to, the icon is a ❓ rather than a speaker symbol, as is shown on the linked page. Is there perhaps some way to properly advertise SpeakerPi as an audio device, that raspbian is not picking up on?

When I pair, it says, to use the audio screen.

Interestingly at this points on the SpeakerPi if I'm running bluetoothctl I see a Connected : yes message followed by a Connected: no message.

If I then type connect xx:yy:zz:xx:yy::zz into SpeakerPi , then back on SourcePi , if I right click on the speaker icon in the top right, SpeakerPi still doesn't show up BUT if I click "device profiles" then SpeakerPi does appear on this screen. It has the following options:

  • High Fidelity Capture (A2DP Source)
  • High Fidelity Capture (A2DP Sink)
  • Off

The middle one of these is what I want. but if I choose it, then it disappears from the "device profiles" screen and SpeakerPi reports it has been disconnected.

Glad you're making progress, but I thought RaspberryPiOS has abandoned bluez-alsa for pulseaudio.

When pulseaudio is properly configured then it takes over all ALSA management and users and applications should just use the pulse API and utilities

Are there any good links available explaining the pros/cons of installing pulseaudio over using alsa?

Most recent posts I can find recommend against pulseaudio. For example this post from less than 4 months ago that says:

DO NOT INSERT PULSEAUDIO - it will disrupt the sound.

I think 4 months ago RaspberryPiOS had not announced it was using pulse. It sounds like you need to install the full RPiOS on SourcePi and use the GUI to set things up.

On SpeakerPi, bluez-alsa will do what you want. It needs no .asoundrc files. But I believe you will need to initiate the BT connection from SourcePi to SpeakerPi to make each live up to its name. Just make sure bluez-alsa is running on SpeakerPi before you try to connect.

As for pros and cons, I think @borine has explained the difference very well above.

reedstonefood commented Jan 3, 2021

It sounds like you need to install the full RPiOS on SourcePi and use the GUI to set things up.

This unfortunately doesn't work, as I've described already.

This unfortunately doesn't work, as I've described already.

Sorry, it wasn't clear you had switched to the full OS, and as noted above all howtos on the net are going to be suspect. Pulseaudio has been in Raspberry Pi OS for only a month. Can you connect from SourcePi to a BT headphone or speaker?

I note also pulseaudio is in Raspberry Pi OS Lite. So I guess you should remove it if using bluez-alsa.

borine commented Jan 4, 2021

I note also pulseaudio is in Raspberry Pi OS Lite. So I guess you should remove it if using bluez-alsa.

The lite image file does not have pulseaudio installed - at least the 20-12-02-raspios-buster-armhf-lite image does not.

graham8 commented Jan 4, 2021

Hmmm. The release notes imply pulseaudio is there.

XECDesign commented Jan 4, 2021

Release notes are the same for all images, so they're a bit misleading. Pulseaudio is not included in the lite image because it drags in too many dependencies.

graham8 commented Jan 4, 2021

because it drags in too many dependencies.

Exactly why we don't like it at OSMC.

borine commented Jan 4, 2021

@reedstonefood - There are possibly thousands of different combinations of setups of audio sub-systems with linux, so it is impossible to recommend any one "best" solution from a simple exchange of comments on a forum. So instead, let me imagine a requirement which hopefully has some similarities to yours.

There is a RPi with attached screen and keyboard on which is run a desktop (eg the latest Raspios image) and a number of different applications each requiring audio output. There is a USB DAC connecting to an amplifier and speakers, and also a need to send audio over bluetooth. This machine is called SourcePi.

There is a second RPi which is headless, and has an I2C HAT digital amplifier connected to a pair of wired speakers. This machine is to be used to play audio from bluetooth sources, and has a minimal OS installed (eg the latest Raspios Lite). It is called SpeakerPi.

The requirement for multiple sound applications and multiple sound outputs on SourcePi makes pulseaudio the simplest option for audio management. It is also a good option, in spite of the many negative posts by people who basically complain about anything and everything. The lastest Raspios full image is already configured with desktop, Chromium browser, and pulseaudio with bluetooth - ready to go (I think, not having actually tried it myself 😃 ).

SpeakerPi has the Raspios Lite image. This has the bluetooth subsystem configured, but with no audio component. So bluealsa and bluealsa-aplay are installed (either from the repository or self-built from sources; if using self-build, the guide on the bluez-alsa project wiki has been followed).

SpeakerPi has its attached sound card configured as default using /etc/asound.conf , and has bluealsa started as:

and bluealsa-aplay started as:

SourcePi and SpeakerPi are paired using bluetoothctl in the usual way. SpeakerPi is set to trust SourcePi so that it automatically accepts connect requests from SourcePi.

On SourcePi, using the desktop audio control panel, SpeakerPi is selected as the default audio sink. Chromium browser is started and a YouTube video plays sound through SpeakerPi with no further configuration required.

Here is what I would like to see accomplished with this issue:

  • Write a tutorial for Bluetooth audio (A2DP) with PulseAudio.
  • See if we can get HSP/HFP using ofono .

I will update these items as they evolve.

New tutorials go here.
Old docs are here.

The text was updated successfully, but these errors were encountered:

BertLindeman commented Nov 10, 2014

Got error(s) after systemctl start pulseaudio.service :

Fixed with:
sudo mkdir -p /var/run/pulse/.config/pulse
and
sudo chown -R pulse:pulse /var/run/pulse

Wonder about bluez4-util.c in the message.

dlech commented Nov 10, 2014

Thanks for checking this out. I did so many things that didn't work, it is hard to tell what extra steps I performed that made it work.

It seems the only issue here is the issue of the existence and permissions of /var/run/pulse . In the "current status" above, I am not getting the warnings about the cookie file not existing, so I must have done something else to create this. I did not have to manually create the directory as you did. The warnings about no $DISPLAY variable and error about bluez4-util are expected because we don't have an X server and we are running BlueZ 5, not 4. There is no error about BlueZ 5, so at least that part is working.

One thing that is different from our case than most of the examples you will find on the web is that we don't have a session (since we are not running a desktop). Because of this, we have a reason to run PulseAudio as a system-wide daemon.

So, one thing to try might be drop the User=pulse line from the systemd service and add the --system options to the ExecStart=. line.

Another thing I did was run su -s /bin/bash pulse to log in as the pulse user.

BertLindeman commented Nov 10, 2014

;-) It's easier to check a scenario than to develop one.

Attempt pulseaudio as system-wide server:
Changed /etc/systemd/system/pulseaudio.service to only get warnings about system mode:

Then reload / restart:
systemctl daemon-reload
systemctl restart pulseaudio.service

status: only warnings about system mode

Maybe not everything is OK, as I see: xcb_connection_has_error() returned true twice
on a simple espeak --stdout "ok" | aplay -q

I had to unpair/pair my device again. Restarting bluetooth service didn't help.


33.5k 24 24 gold badges 84 84 silver badges 166 166 bronze badges


@guntbert: The first sentence looks like an answer to me. @guntbert: The second sentence certainly appear to be a comment to that. The first sentence is a valid, self-contained answer. (I cannot confirm its veracity but that doesn’t matter to its classification as an answer here.)

run this to reset its configuration. turn off and on bluetooth and connect bluetooth headphone again. i had same issue on ubuntu 16.10 and it solve it! in this case you don't need blueman. run this and in Sound setting select your headphone

I get "Connection Failed: blueman.bluez.errors.DBusFailedError: Host is down" now This works for me, thank. Is there a more permanent fix for this ?

I often have this issue:

blueman.bluez.errors.DBusFailedError: Resource temporarily unavailable

with blueman on Ubuntu Mate 18.04 when waking the machine up from suspension.

Simply restarting the bluetooth service with:

and rescanning usually resolves the issue quite easily.


1,156 6 6 gold badges 12 12 silver badges 19 19 bronze badges

I used the following command and it solved my problem:

Then try to reconnect your bluetooth headset.

Thank you! Arch users install the following aur: "pulseaudio-modules-bt" and restart bluetooth "sudo systemctl restart bluetooth". No need to reconnect anything. Just works as it should. Awesome!

I received this error as the headset was already connected to another device (my phone). Check that the device you are wanting to connect to your Ubuntu instance is not already connected to another device, such as a mobile telephone, and then try to connect again.

Try restarting Pulse Audio, as also mentioned above. These commands worked for me.

One very easy thing you have to try before anything else, is check that there isn't any other device that is already connected to the device via bluetooth. For me it was my phone, which was connecting to a bluetooth speaker automatically. Once I disconnected it and restarted bluetooth adapter on my machine it worked out.

Читайте также: