Skip to content

Instantly share code, notes, and snippets.

@savegame
Last active April 26, 2024 19:54
Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save savegame/58ae5966c58a71fda5d3800b335eb2f5 to your computer and use it in GitHub Desktop.
Save savegame/58ae5966c58a71fda5d3800b335eb2f5 to your computer and use it in GitHub Desktop.
PulseAudio / PipeWire streaming audio from Client to remote PulseAudio / PipeWire Server

We have Server machine, this computer with Headphones, and we have Client computer, this is remote PC with music =) On Server we should first open port for listening connections from Client :

# on ubuntu 
sudo ufw allow from <Client_IP> to any port 4656 proto tcp
# on fedora ( with firewalld ) 
sudo firewall-ctl --add-port 4656/tcp

note: port 4656 just for sample. you can use any port you want
than on Server, from current user add listening for connections

pactl load-module module-native-protocol-tcp port=4656 listen=<Server_IP>
Note: set real IP for listening, not localhost or 127.0.0.1, its should be IP avaliable from Client

then on Client add sink to remote Server

pactl load-module module-tunnel-sink server=tcp:<Server_IP>:4656

than, you should chose right output on Client, in KDE it looks like изображение
you can use pavucontrol for this too

Update from comments :
maybe add anonynous authorisation helps (thanks to @raldone01)

pactl load-module module-native-protocol-tcp port=4656 listen=0.0.0.0 auth-anonymous=true
@musicfunfan
Copy link

musicfunfan commented May 5, 2022

This is not working for me. i am on archlinux i use pipwire 0.3.51. On laptop (streaming maching) i have an error.
when i run pactl load-module module-tunnel-sink server=tcp:<Server_IP>:4656
Failure: No such entity.
I am thinking to re-install pulseaudio to try it.

@savegame
Copy link
Author

savegame commented May 6, 2022

@musicfunfan did you open port on Server first? you can check if it available with nmap from Client computer

nmap -Pn -p4656 <Server_IP>

@musicfunfan
Copy link

@savegame I wend back to pulseaudio on both machines and working fine. I do not have the pacthbay on pulseaudio but the audio streaming is more important so.

Also for the question you ask i do not have firewall so all ports are open. For pulse is working so all good.

Thenx for the response.

@savegame
Copy link
Author

savegame commented May 7, 2022

@musicfunfan in my case on both machines are pipewire )

@musicfunfan
Copy link

musicfunfan commented May 7, 2022

@savegame I do not know what i do wrong tbh...
This is what i try to do:

On pulseaudio (the system i want to stream audio from)

On the ~/.profile file

export PULSE_SERVER="tcp:192.168.1.3"

test "$DISPLAY" && pax11publish -e || true

On pipewire (the system i want the audio output)
On start up file ~/.profile

pactl load-module module-native-protocol-tcp

What happened.

pulseaudio does not start and i get the error when i try to start it manual with the pulseaudio --start
N: [pulseaudio] main.c: User-configured server at tcp:192.168.1.3, refusing to start/autospawn.

I use:

archlinux both systems
pipewire version =

pipewire
Compiled with libpipewire 0.3.51
Linked with libpipewire 0.3.51

and also i use pipewire-pulse

pulseaudio version = pulseaudio 15.0

Same configuration is working with pulseaudio on both systems.

@savegame
Copy link
Author

savegame commented May 7, 2022

@musicfunfan , did you try set listen IP directlry

pactl load-module module-native-protocol-tcp listen=<host_ip_address>

in my case, if set listen=127.0.0.1 - its not work, only if i set IP, which is avaliable from Client Machine (where we play music and streaming it to network) ...
i mean, if on Server ( where we listen music with headphones ) i has IP 192.168.1.10, than i set it to listen

pactl load-module module-native-protocol-tcp listen=192.168.1.10

@musicfunfan
Copy link

@savegame Well now is working fine. I just needed to install the WirePlumber instead of the media-session only problem now is that i do not have control of the volume on laptop (sender) but i have only in pc (receiver).

Also now i am with pipewire on both systems.

@vdevalerio
Copy link

vdevalerio commented Apr 9, 2023

Hi, it is not working for me. I want to send audio from an Ubuntu machine with PulseAudio to an ArchLinux machine with PipeWire.

Steps:

  1. On Ubuntu:
    $ sudo ufw allow from <ArchLinux IP address> to any port 4656 proto tcp
    Rule added

  2. $ pactl load-module module-native-protocol-tcp port=4656 listen=<Ubuntu IP address>
    23

  3. On ArchLinux:
    $ pactl load-module module-tunnel-sink server=tcp:<Ubuntu IP address>:4656
    Connection failure: Connection terminated

What did I miss here?

$ nmap -Pn -p4656 <Ubuntu IP address>
Starting Nmap 7.93 ( https://nmap.org ) at 2023-04-08 23:42 -03
Nmap scan report for pc (<Ubuntu IP address>)
Host is up (0.011s latency).

PORT STATE SERVICE
4656/tcp open unknown

Nmap done: 1 IP address (1 host up) scanned in 0.03 seconds

@steveoriol
Copy link

same as vdevalerio,
it is not working for me with server and client on pipewire

@ModProg
Copy link

ModProg commented Apr 18, 2023

With pipewire there is a new player that in my experimentation worked quite well pipewire-roc:
https://gavv.net/articles/roc-tutorial-0.2/#linux-desktop-pipewire

@raldone01
Copy link

I had to add auth anonymous: pactl load-module module-native-protocol-tcp port=4656 listen=0.0.0.0 auth-anonymous=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment