# How to redirect Pulse-audio over SSH and open up a socket file reverse tunnelled to the local Pulse-audio server on the client.



## ziomario (Aug 3, 2021)

Hello.​
I've installed TurboVNC + VirtualGL on Debian 10 virtualized with Bhyve on FreeBSD 13,but the audio does not work. From this post :

https://www.reddit.com/r/freebsd/comments/ow0f7f/i_have_installed_turbovnc_virtualgl_on_debian_10/

I've got the following suggestion :



> The gist of my configuration is as follows:
> 
> 
> on the server I set export PULSE_SERVER=unix:~/.vnc/audio.socket in the .zshenv file for the user (you use whichever shell environment file is   appropriate for your setup).  This should probably be set by some server  side VNC script but I haven’t got to that yet.
> ...



I need to better understand what to do. I'm not sure if I have understood well,because it doesn't work well. So,this is what I did :

1) on the Debian file called /home/mariuccio/.bashrc and also in /root/.bashrc I've added :


```
export PULSE_SERVER=unix:/home/mariuccio/.vnc/audio.socket
```

*(file audio.socket is present only on /home/mariuccio/.vnc,it is not present in /root/.vnc)*

2) on FreeBSD,inside the file /usr/local/etc/default.pa I've added this line :


```
2) module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1
```

3) This is the file /etc/ssh/sshd_config that I have created on Debian and on FreeBSD : (actually they have the same content inside)


```
PermitRootLogin yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
PasswordAuthentication yes
UsePAM yes
AllowAgentForwarding yes
AllowTcpForwarding yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
```


This is what happens when I try to redirect Pulse-audio over SSH to open up a socket file  reverse tunnelled from the local Pulse-audio server to the client.


From FreeBSD I write :

*root@marietto:~ # ssh -L 5901:localhost:5901 192.168.1.8 -R /home/mariuccio/.vnc/audio.socket:localhost:4713 firefox*


```
root@192.168.1.8's password:
Warning: remote port forwarding failed for listen path /home/mariuccio/.vnc/audio.socket
Error: no DISPLAY environment variable specified
```

Instead,if I do this as normal user :

*marietto@marietto:~ $ ssh -L 5901:localhost:5901 192.168.1.8 -R /home/mariuccio/.vnc/audio.socket:localhost:4713 firefox*


```
Password:
Password:
Password:
Password:
password is never accepted. I tried to change it several times.
```

Something is wrong in this kind of configuration and I don't know what it is. Inside Debian I tried to do ssh with the IP of Debian itself and it worked.






But it doesn't if I do this from FreeBSD :

marietto@marietto:~ $ ssh -L 5901:localhost:5901 192.168.1.8

Password:
Password:


----------



## sko (Aug 3, 2021)

Did network sound even work (synchronously and without artifacts) at any time with pulseaudio? I remember this being an issue for years...

My suggestion: use sndio - its much cleaner, is well maintained and supported and has built-in network support that actually works (so no need for all the ssh tunnel shenanigans). It also behaves like a proper service, i.e. is started via rc.conf and does not spawn randomly in the background even if you've never enabled it...


----------



## ziomario (Aug 3, 2021)

sko said:


> Did network sound even work (synchronously and without artifacts) at any time with pulseaudio? I remember this being an issue for years...
> 
> My suggestion: use sndio - its much cleaner, is well maintained and supported and has built-in network support that actually works (so no need for all the ssh tunnel shenanigans). It also behaves like a proper service, i.e. is started via rc.conf and does not spawn randomly in the background even if you've never enabled it...



In freeBSD sound works well here. But inside the Debian VM it does not detect any input or output source.


----------



## SirDice (Aug 3, 2021)

Please understand that VNC does not support audio, at all. All the tricks you found are basically kludges to somehow transport audio over the network to the client.


----------



## ziomario (Aug 3, 2021)

Help me to understand. Using sndio can I hear sounds inside the Debian VM,too ? Do u have a tutorial that explains how to configure it ?


----------



## ziomario (Aug 3, 2021)

SirDice said:


> Please understand that VNC does not support audio, at all. All the tricks you found are basically kludges to somehow transport audio over the network to the client.



Are u sure of this ? On my jetson nano I did the same configuration (turbovnc + virtual GL + x11vnc and using an usb key sound card I can hear sounds very well)


----------



## SirDice (Aug 3, 2021)

ziomario said:


> Are u sure of this


Quite sure.


ziomario said:


> On my jetson nano I did the same configuration (turbovnc + virtual GL + x11vnc and using an usb key I can hear sounds very well)


The pulse-audio trick you posted uses a separate network connection to connect the pulse-audio from the VM to the pulse-audio running on the host. This does not use the VNC connection.


----------



## sko (Aug 3, 2021)

remote audio is not a standard VNC feature! you either have to use a VNC server/client combination that has a common implementation of redirecting sound or you have to redirect all sound output from the debian VM to the sndio network listener (e.g. via `sndiod -L 0.0.0.0`) on the FreeBSD host.

I haven't touched linux or debian for quite a while (at least nothing desktop related), so I'm not sure how you configure a default sound device on linux nowadays, but it should redirect to snd@<hostip>/0


----------



## ziomario (Aug 3, 2021)

Where should be configured sndiod? on Debian or on FreeBSD? I've installed the package sndiod in Debian with apt-get but I didn't find any of equivalent on FreeBSD :

```
marietto@marietto:~ # pkg install sndiod
Updating FreeBSD repository catalogue...
Fetching packagesite.txz: 100%    6 MiB   1.7MB/s    00:04   
Processing entries: 100%
FreeBSD repository update completed. 30735 packages processed.
All repositories are up to date.
pkg: No packages available to install matching 'sndiod' have been found in the repositories
marietto@marietto:~ # find / -name sndiod
nothing
```

Keeping in consideration that the sound server is on FreeBSD,the sound should start from there and go to Debian,right ? so sndiod should be configured on Freebsd ?


----------



## SirDice (Aug 3, 2021)

ziomario said:


> I didn't find any of equivalent on FreeBSD


audio/sndio


----------



## ziomario (Aug 3, 2021)

I found this website and I tried : https://not.just-paranoid.net/network-audio-and-sndio/

"He has Ubuntu on the local machine, and FreeBSD on the remote side with the speakers"

I have FreeBSD on the local machine and Debian on the VM. So:

On FreeBSD :

```
root@marietto:~ # echo $DISPLAY
:0.0

root@marietto:~ # sndiod -dd -L 0.0.0.0

snd0.default: rec=0:1 play=0:1 vol=32768 dup
```
On Debian :

```
mariuccio@marietto:~ # echo $DISPLAY 
nothing

mariuccio@debian:~$ AUDIODEVICE="snd@192.168.1.6" vlc

VLC media player 3.0.12 Vetinari (revision 3.0.12-1-0-gd147bb5e7e)
[000055c16cd30fa0] vlcpulse audio output error: PulseAudio server connection failure: Connessione rifiutata
[000055c16cd95770] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[000055c16cd95770] main interface error: no suitable interface module
[000055c16cc74570] main libvlc error: interface "dbus,none" initialization failed
[000055c16cd93150] main interface error: no suitable interface module
[000055c16cc74570] main libvlc error: interface "globalhotkeys,none" initialization failed
[000055c16cc74570] main libvlc: Esecuzione di vlc con l'interfaccia predefinita. Usa 'cvlc' per utilizzare vlc senza interfaccia.
error: XDG_RUNTIME_DIR not set in the environment.
[000055c16cd93150] skins2 interface error: cannot initialize OSFactory
[000055c16cc784e0] main playlist: playlist is empty
[000055c16cd93150] [cli] lua interface: Listening on host "*console".
```
same result with : 
	
	



```
mariuccio@debian:~$ AUDIODEVICE="snd@0.0.0.0" vlc
```


----------



## kpedersen (Aug 3, 2021)

Is the VirtualGL worthwhile in a Bhyve VM? VirtualGL is intended to run on the host's (i.e the one running the vncserver) GPU and then funnel back the image. If the host is running virtualized all it has is LLVMpipe anyway?


----------



## ziomario (Aug 3, 2021)

This is how I have  installed TurboVNC + VirtualGL on the Debian VM :






						r/freebsd - I have installed TurboVNC + VirtualGL on Debian 10 virtualized with bhyve on FreeBSD 13,but the audio does not work...
					

9 votes and 13 comments so far on Reddit




					www.reddit.com


----------



## ziomario (Aug 3, 2021)

kpedersen said:


> Is the VirtualGL worthwhile in a Bhyve VM? VirtualGL is intended to run on the host's (i.e the one running the vncserver) GPU and then funnel back the image. If the host is running virtualized all it has is LLVMpipe anyway?



help me to understand what to do. Im not so experienced like you.


----------



## ziomario (Aug 3, 2021)

SirDice said:


> Quite sure.
> 
> The pulse-audio trick you posted uses a separate network connection to connect the pulse-audio from the VM to the pulse-audio running on the host. This does not use the VNC connection.



but on the jetson nano I don't use tricks. I suspect that on that board there are installed a lot of mesa libraries and LLVMpipe...so should I do the same in debian virtualized with bhyve ?


----------



## SirDice (Aug 4, 2021)

ziomario said:


> I suspect that on that board there are installed a lot of mesa libraries and LLVMpipe


Those have nothing to do with audio.


----------



## ziomario (Aug 4, 2021)

SirDice said:


> Those have nothing to do with audio.



ok,but I still don't understand why on the jetson nano I can hear sounds when I connect vncviewer to turbovnc + virtual-gl installed to the board,while in the debian + bhyve it does not work. And I don't keep any monitor attached to the board. It is in headless mode. And I don't use any ssh tunnelling or forwarding.


----------



## kpedersen (Aug 4, 2021)

Hmm. What vncviewer are you using? VNC usually only deals with graphics unless someone has hacked in the audio feature.

When you are logged in via vncviewer, can you open up a terminal and list environment variables (type `env`) and post them here? Then we can perhaps see if there is any pulse audio going on. I am inclined to believe that is the only thing making this possible but it still shouldn't work via the viewer.

And you are *sure* that the Jetson Nano's HDMI isn't plugged into a monitor and playing through the speakers there?


----------



## Geezer (Aug 4, 2021)

Maybe use `rdp` instead of `vnc`. `rdp` is a _windowsee_ thing, but there is a client, `xfreerdp` in the ports that you could use on the host, and try and find some rdp server for debian.

I use `rdp` with a `bhyve` running *windows 10*, and the sound works seamlessly.


----------



## Geezer (Aug 4, 2021)

ziomario One big question I have got is why?

The various desktops and programs that run on debian, are pretty much the same as those that run on Freebsd. Why do you want a full working desktop on debian, virtualised and displayed on a Freebsd desktop?


----------



## kpedersen (Aug 4, 2021)

Geezer said:


> ziomario One big question I have got is why?


I think he is trying to run it on the Jetson Nano (which FreeBSD doesn't support). That said, I thought the Jetson Nano only supported Ubuntu, not Debian. It doesn't seem very clear.


----------



## ziomario (Aug 4, 2021)

Geezer said:


> ziomario One big question I have got is why?
> 
> The various desktops and programs that run on debian, are pretty much the same as those that run on Freebsd. Why do you want a full working desktop on debian, virtualised and displayed on a Freebsd desktop?



because usually I use rambox on Debian (it's a multi social network tool. It means that it includes a lot of social networks in one only graphical interface),but it does not work on FreeBSD,but only on Debian. The problem is that the audio does not work on Debian,so it makes no sense to use it if I can't hear any voice messages sent by my friends.


----------



## eternal_noob (Aug 4, 2021)

ziomario said:


> I use rambox on Debian ... but it does not work on FreeBSD


Can't you just use the linuxulator? Maybe bhyve isn't the right tool?


----------



## ziomario (Aug 4, 2021)

At the moment I haven't tried the linux emulator,but I read that it is pretty limited. why using it instead of bhyve,that can offer to me a complete linux emulation ? I've just configured xrdp server on debian :


```
root@debian:~/Scrivania/tmp/mesa/build# ifconfig

enp0s5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.8  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::5a9c:fcff:fe03:3360  prefixlen 64  scopeid 0x20<link>
        ether 58:9c:fc:03:33:60  txqueuelen 1000  (Ethernet)
        RX packets 12730807  bytes 2108501513 (1.9 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 23326444  bytes 34132082669 (31.7 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
```


```
root@debian:~/Scrivania/tmp/mesa/build# apt install xrdp

Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze    
Lettura informazioni sullo stato... Fatto
I seguenti pacchetti aggiuntivi saranno inoltre installati:
  xorgxrdp
Pacchetti suggeriti:
  guacamole xrdp-pulseaudio-installer
I seguenti pacchetti NUOVI saranno installati:
  xorgxrdp xrdp
0 aggiornati, 2 installati, 0 da rimuovere e 2 non aggiornati.
È necessario scaricare 607 kB di archivi.
Dopo quest'operazione, verranno occupati 3.941 kB di spazio su disco.
Continuare? [S/n] s
Scaricamento di:1 http://deb.debian.org/debian buster/main amd64 xorgxrdp amd64 1:0.2.9-1 [172 kB]
Scaricamento di:2 http://deb.debian.org/debian buster/main amd64 xrdp amd64 0.9.9-1+deb10u1 [435 kB]
Recuperati 607 kB in 0s (2.843 kB/s)
Selezionato il pacchetto xorgxrdp non precedentemente selezionato.
(Lettura del database... 367925 file e directory attualmente installati.)
Preparativi per estrarre .../xorgxrdp_1%3a0.2.9-1_amd64.deb...
Estrazione di xorgxrdp (1:0.2.9-1)...
Selezionato il pacchetto xrdp non precedentemente selezionato.
Preparativi per estrarre .../xrdp_0.9.9-1+deb10u1_amd64.deb...
Estrazione di xrdp (0.9.9-1+deb10u1)...
Configurazione di xrdp (0.9.9-1+deb10u1)...

Generating 2048 bit rsa key...

ssl_gen_key_xrdp1 ok

saving to /etc/xrdp/rsakeys.ini

Created symlink /etc/systemd/system/multi-user.target.wants/xrdp-sesman.service → /lib/systemd/system/xrdp-sesman.service.
Created symlink /etc/systemd/system/multi-user.target.wants/xrdp.service → /lib/systemd/system/xrdp.service.
Configurazione di xorgxrdp (1:0.2.9-1)...
Elaborazione dei trigger per systemd (241-7~deb10u8)...
Elaborazione dei trigger per man-db (2.8.5-2)...
Elaborazione dei trigger per libc-bin (2.28-10)...
root@debian:~/Scrivania/tmp/mesa/build# sudo systemctl status xrdp
● xrdp.service - xrdp daemon
   Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2021-08-05 00:28:54 CEST; 23s ago
     Docs: man:xrdp(8)
           man:xrdp.ini(5)
 Main PID: 31040 (xrdp)
    Tasks: 1 (limit: 4915)
   Memory: 1.6M
   CGroup: /system.slice/xrdp.service
           └─31040 /usr/sbin/xrdp

ago 05 00:28:53 debian xrdp[31038]: (31038)(139680190314304)[DEBUG] Testing if xrdp can listen on 0.0.0.0 port 3389.
ago 05 00:28:53 debian xrdp[31038]: (31038)(139680190314304)[DEBUG] Closed socket 7 (AF_INET6 :: port 3389)
ago 05 00:28:53 debian systemd[1]: xrdp.service: Can't open PID file /run/xrdp/xrdp.pid (yet?) after start: No such file or directory
ago 05 00:28:54 debian systemd[1]: Started xrdp daemon.
ago 05 00:28:54 debian systemd[1]: /lib/systemd/system/xrdp.service:8: PIDFile= references path below legacy directory /var/run/, upda
ago 05 00:28:54 debian systemd[1]: /lib/systemd/system/xrdp.service:8: PIDFile= references path below legacy directory /var/run/, upda
ago 05 00:28:54 debian systemd[1]: /lib/systemd/system/xrdp.service:8: PIDFile= references path below legacy directory /var/run/, upda
ago 05 00:28:55 debian systemd[1]: /lib/systemd/system/xrdp.service:8: PIDFile= references path below legacy directory /var/run/, upda
ago 05 00:28:55 debian xrdp[31040]: (31040)(139680190314304)[INFO ] starting xrdp with pid 31040
ago 05 00:28:55 debian xrdp[31040]: (31040)(139680190314304)[INFO ] listening to port 3389 on 0.0.0.0
root@debian:~/Scrivania/tmp/mesa/build# sudo adduser xrdp ssl-cert
Aggiunta dell'utente «xrdp» al gruppo «ssl-cert» ...
Aggiunta dell'utente xrdp al gruppo ssl-cert
```

and I tried to connect the xfreerdp client to the debian IP 192.168.1.8 and this is what happened :

root@marietto:~ # xfreerdp 192.168.1.8


```
[00:38:03:412] [6115:02212000] [WARN][com.freerdp.client.common.cmdline] - Using deprecated command-line interface!
[00:38:03:426] [6115:02212000] [WARN][com.freerdp.client.common.compatibility] - 192.168.1.8 -> /v:192.168.1.8
[00:38:03:426] [6115:02212000] [WARN][com.freerdp.client.common.compatibility] -
[00:38:03:426] [6115:02212500] [INFO][com.freerdp.core] - freerdp_connect:freerdp_set_last_error_ex resetting error state
[00:38:03:430] [6115:02212500] [INFO][com.freerdp.client.common.cmdline] - loading channelEx rdpdr
[00:38:03:438] [6115:02212500] [INFO][com.freerdp.client.common.cmdline] - loading channelEx rdpsnd
[00:38:03:438] [6115:02212500] [INFO][com.freerdp.client.common.cmdline] - loading channelEx cliprdr
[00:38:03:438] [6115:02212500] [INFO][com.freerdp.client.x11] - No user name set. - Using login name: root
[00:38:03:793] [6115:02212500] [INFO][com.freerdp.primitives] - primitives autodetect, using optimized
[00:38:04:865] [6115:02212500] [INFO][com.freerdp.core] - freerdp_tcp_is_hostname_resolvable:freerdp_set_last_error_ex resetting error state
[00:38:04:865] [6115:02212500] [INFO][com.freerdp.core] - freerdp_tcp_connect:freerdp_set_last_error_ex resetting error state
[00:38:05:074] [6115:02212500] [INFO][com.freerdp.gdi] - Local framebuffer format  PIXEL_FORMAT_BGRX32
[00:38:05:074] [6115:02212500] [INFO][com.freerdp.gdi] - Remote framebuffer format PIXEL_FORMAT_RGB16
[00:38:05:146] [6115:02212500] [INFO][com.winpr.clipboard] - initialized POSIX local file subsystem
[00:38:05:148] [6115:02212500] [INFO][com.freerdp.channels.rdpsnd.client] - [static] Loaded fake backend for rdpsnd
[00:38:05:150] [6115:02212500] [ERROR][com.freerdp.core.update] - [0x03] Cache Glyph - SERVER BUG: The support for this feature was not announced! Use /relax-order-checks to ignore
[00:38:05:150] [6115:02212500] [ERROR][com.freerdp.core.update] - order flags 03 failed
[00:38:05:150] [6115:02212500] [ERROR][com.freerdp.core.fastpath] - Fastpath update Orders [0] failed, status 0
[00:38:05:150] [6115:02212500] [ERROR][com.freerdp.core.fastpath] - fastpath_recv_update() - -1
[00:38:05:150] [6115:02212500] [ERROR][com.freerdp.core.fastpath] - fastpath_recv_update_data() fail
[00:38:05:203] [6115:02212500] [ERROR][com.freerdp.core.transport] - transport_check_fds: transport->ReceiveCallback() - -3
[00:38:05:203] [6115:02212500] [ERROR][com.freerdp.core] - freerdp_check_fds() failed - 0
[00:38:05:203] [6115:02212500] [INFO][com.freerdp.client.common] - Network disconnect!
[00:38:05:203] [6115:02212500] [ERROR][com.freerdp.client.x11] - Failed to check FreeRDP file descriptor
```


----------



## ziomario (Aug 4, 2021)

```
root@marietto:~ # xfreerdp 0.0.0.0:3389

[00:48:25:110] [6130:02212000] [WARN][com.freerdp.client.common.cmdline] - Using deprecated command-line interface!
[00:48:25:111] [6130:02212000] [WARN][com.freerdp.client.common.compatibility] - 0.0.0.0 -> /v:0.0.0.0
[00:48:25:111] [6130:02212000] [WARN][com.freerdp.client.common.compatibility] -
[00:48:25:111] [6130:02212500] [INFO][com.freerdp.core] - freerdp_connect:freerdp_set_last_error_ex resetting error state
[00:48:25:111] [6130:02212500] [INFO][com.freerdp.client.common.cmdline] - loading channelEx rdpdr
[00:48:25:111] [6130:02212500] [INFO][com.freerdp.client.common.cmdline] - loading channelEx rdpsnd
[00:48:25:111] [6130:02212500] [INFO][com.freerdp.client.common.cmdline] - loading channelEx cliprdr
[00:48:25:111] [6130:02212500] [INFO][com.freerdp.client.x11] - No user name set. - Using login name: root
[00:48:25:418] [6130:02212500] [INFO][com.freerdp.primitives] - primitives autodetect, using optimized
[00:48:25:420] [6130:02212500] [INFO][com.freerdp.core] - freerdp_tcp_is_hostname_resolvable:freerdp_set_last_error_ex resetting error state
[00:48:25:420] [6130:02212500] [INFO][com.freerdp.core] - freerdp_tcp_connect:freerdp_set_last_error_ex resetting error state
[00:48:25:420] [6130:02212500] [ERROR][com.freerdp.core] - unable to set TCP_NODELAY
[00:48:25:420] [6130:02212500] [WARN][com.freerdp.core] - setsockopt() IPPROTO_TCP, TCP_KEEPIDLE
[00:48:25:420] [6130:02212500] [WARN][com.freerdp.core] - setsockopt() SOL_TCP, TCP_KEEPCNT
[00:48:25:420] [6130:02212500] [WARN][com.freerdp.core] - setsockopt() SOL_TCP, TCP_KEEPINTVL
[00:48:25:420] [6130:02212500] [ERROR][com.freerdp.core.transport] - BIO_should_retry returned a system error 32: Broken pipe
[00:48:25:420] [6130:02212500] [ERROR][com.freerdp.core] - transport_write:freerdp_set_last_error_ex ERRCONNECT_CONNECT_TRANSPORT_FAILED [0x0002000D]
[00:48:25:424] [6130:02212500] [INFO][com.freerdp.core] - freerdp_tcp_is_hostname_resolvable:freerdp_set_last_error_ex resetting error state
[00:48:25:424] [6130:02212500] [INFO][com.freerdp.core] - freerdp_tcp_connect:freerdp_set_last_error_ex resetting error state
[00:48:25:424] [6130:02212500] [ERROR][com.freerdp.core] - unable to set TCP_NODELAY
[00:48:25:424] [6130:02212500] [WARN][com.freerdp.core] - setsockopt() IPPROTO_TCP, TCP_KEEPIDLE
[00:48:25:424] [6130:02212500] [WARN][com.freerdp.core] - setsockopt() SOL_TCP, TCP_KEEPCNT
[00:48:25:424] [6130:02212500] [WARN][com.freerdp.core] - setsockopt() SOL_TCP, TCP_KEEPINTVL
[00:48:25:424] [6130:02212500] [ERROR][com.freerdp.core.transport] - BIO_should_retry returned a system error 32: Broken pipe
[00:48:25:424] [6130:02212500] [ERROR][com.freerdp.core] - transport_write:freerdp_set_last_error_ex ERRCONNECT_CONNECT_TRANSPORT_FAILED [0x0002000D]
[00:48:25:424] [6130:02212500] [ERROR][com.freerdp.core] - freerdp_post_connect failed
```


----------



## ziomario (Aug 5, 2021)

[ERROR][com.freerdp.core.update] - [0x03] Cache Glyph - SERVER BUG: The support for this feature was not announced! Use /relax-order-checks to ignore · Issue #7216 · FreeRDP/FreeRDP
					

Hello. I've installed TurboVNC + VirtualGL on Debian 10 virtualized with Bhyve on FreeBSD 13,but the audio does not work,so in the FreeBSD forum they have suggested : "Maybe use rdp instea...




					github.com


----------



## Geezer (Aug 5, 2021)

Are you merging threads from two different forums?


----------



## cmoerz (Aug 5, 2021)

I feel your pain. I've been in a similar spot before when I tried to get Netflix working via a Linux VM. In the end I went with the Linux emulation layer because it turned out to be less painful.

Having said that, and not knowing your particular use case, let me add something that I did not see mentioned while walking through this thread:

you are not seeing any audio input or audio output when connecting via VNC because there is no audio device on the VM; I looked into audio on bhyve and there appears to be some patches but I failed to make them work for me. Still, this probably is not required for your desired setup anyways.
There used to be a really good write up on pulseaudio by Colin Guthrie; it appears written up for Linux, but the general message applies to BSD just fine. It appears to be down at the moment. I'm still leaving the URL in the hopes that it'll turn up again eventually: http://colin.guthr.ie/2009/08/sound-on-linux-is-confusing-defuzzing-part-2-pulseaudio/
To get audio on xrdp, you will probably need some audio device or plugin. A google search revealed https://github.com/neutrinolabs/pulseaudio-module-xrdp but I can't say whether this really works since I never tried it myself. (that's wrong as shown by other posts)
Alternatively, you might also want to check out x11/xpra, which has audio transport built in as well and would allow you to use applications seemlessly. I liken it to a Citrix session though there's quite some technical differences, obviously. Not sure whether this requires a remote audio device, a dummy dev might still do the trick, I suppose.


----------



## Geezer (Aug 5, 2021)

cmoerz said:


> because there is no audio device on the VM; I looked into audio on bhyve



Really? I seem to have sound working on my bhyve (windows 10). I can hear all the system sounds and play music within windows (if I wanted), and whatever else. Sound seems to work in bhyve.


----------



## cmoerz (Aug 5, 2021)

Quote


Geezer said:


> Sound seems to work in bhyve.



Interesting. I must have missed something then. I'm still on 12.2; my bhyve()'s emulation section lists no audio device. I suppose you are seeing a virtual audio device from xrdp and we're likely referring to two different things?

Also, turns out the xrdp plugin is for audio input, not output. Serves me right for attempting to speed read a Github readme. So, that's not right.
Thanks Geezer for following up - made me look twice and gives me a chance to correct my mistake.


----------



## Geezer (Aug 5, 2021)

For your reference:
`BHYVE_FLAGS="    \
    -c sockets=1,cores=2,threads=2    \
    -m 6G    \
    -H    \
    -w    \
    -U whatever-whatever-whatever-whatever    \
    -s 0,hostbridge    \
    -s 4,ahci-hd,window.10.pro.64.disk.img    \
    -s 5,virtio-net,tap0    \
    -s 29,fbuf,tcp=0.0.0.0:5900,wait    \
    -s 30,xhci,tablet    \
    -s 31,lpc    \
    -l com1,stdio    \
    -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd    \
"`

Now on 13.0, used to work on 12.X as well.


----------



## cmoerz (Aug 5, 2021)

Alright, it's embarrassing. I've been using net/remmina and never realized that my RDP connection had audio disabled. Setting it to local output suddenly makes it work on my end as well. Again, thanks Geezer. Sometimes it takes a nudge to not leave it at "doesn't work for me but I don't need it anyways". 

Apologies for kind of hijacking this thread. At least it's a confirmation that RDP audio redirection works quite well... I just tested this with net/xrdp based on FreeBSD. That works just fine too - as long as you consider the audio option of your RDP connection. It's not the same quality as Linux emulation, I'd like to add though...

For reference: in remmina, go to Advanced tab for an RDP connection, set audio output mode to "Local". You'll need net/freerdp installed for RDP to work in remmina, if I remember correctly.


----------



## ziomario (Aug 5, 2021)

Below you can see me connected to the jetson nano through turbo vnc that I'm hearing a song on youtube. I'm using the Unitek usb stick with an audio jack connected to the speakers. If the audio does not come from VNC I don' care so much. If It will work using another method its ok for me.


----------



## Geezer (Aug 5, 2021)

Yes cmoerz , easy to overlook but quite useful.



ziomario said:


> Below you can see me connected to the jetson nano through turbo vnc that I'm hearing a song on youtube. I'm using the Unitek usb stick with an audio jack connected to the speakers. According with your posts,I shouldn't hear anything ?



I don't know what you can hear, but whatever, *it is not coming through vnc*.


----------



## cmoerz (Aug 5, 2021)

ziomario said:


> I'm hearing a song on youtube



Not sure, if you're referring to my statement or previous posts. Just to clarify: I pointed out the lack of audio emulation in bhyve VMs. That doesn't stop you from using virtual devices as they are offered by RDP.

If you connect to a hardware device with audio capability, playing audio remotely via VNC will certainly still work - as you confirmed. It will however not play back locally on the computer you are running TightVNC on. It will play on the audio jack and audio hardware of the remote device. 

Hence, if you connect to a bhyve VM with VNC, you'll only have the audio output option that's in the VM - which is none, because there is no audio emulation. Unless you successfully patch in some audio support. As stated before - that didn't work for me but YMMV.


----------



## ziomario (Aug 5, 2021)

so. If I attach the usb audio stick to the PC where runs Debian emulated with bhyve and I will pass the usb port through bhyve or even the whole USB controller,it will work ? If the audio does not come from VNC I don' care so much. If It will work using another method its ok for me. Anyway,I didn't understand what you are suggesting me to do.


----------



## ziomario (Aug 5, 2021)

Geezer said:


> View attachment 10894
> 
> For your reference:
> `BHYVE_FLAGS="    \
> ...


We are using different OS. So,I should assume that for you it works because you are using Windows and Instead,I'm emulating Debian ? In addition I'm not using bhyve,but vm-bhyve. I still have a problem that no one has been able to help me to fix. This : https://forums.freebsd.org/threads/...ause-the-error-network-unreachable-n-2.81340/


----------



## Geezer (Aug 5, 2021)

ziomario said:


> In addition I'm not using bhyve,but vm-bhyve.



Really?


----------



## cmoerz (Aug 5, 2021)

ziomario said:


> so. If I attach the usb audio stick to the PC where runs Debian emulated with bhyve and I will pass the usb port through bhyve or even the whole USB controller,it will work ? If the audio does not come from VNC I don' care so much. If It will work using another method its ok for me. Anyway,I didn't understand what you are suggesting me to do.


Not sure, I believe bhyve does not support USB passthrough. There's PCI passthrough, haven't seen that for USB yet.

You could either use RDP (xrdp/freerdp), which will provide a virtual audio device in your Debian VM that plays back on your RDP client; or you could try forwarding a pulseaudio port via SSH. There appear to be some resources on that matter - I have not tried this myself but know from sharing my portaudio socket with the FreeBSD linux emulation that the technique works quite well. It should work just fine over SSH too.

I'm certain there's other options with sndio or alsa; I'm just highlighting two that I'm confident will lead to a working solution.



			SSH - Forwarding X11 and sound - Debian User Forums
		










						Forwarding audio like X in SSH
					

While it is possible to use X applications remotely by using -X switch in ssh, the sound is being played in remote machine's speaker only. For example if I view a film in VLC/Totem only video is vi...




					superuser.com


----------



## ziomario (Aug 5, 2021)

I'm trying to use xrdp but it is not working. If u want,give a look here : https://github.com/FreeRDP/FreeRDP/issues/7216

I tried to use SSH also,but even this tecnique is not working. u can check the first posts of this thread.


----------



## ziomario (Aug 5, 2021)

Anyway,I can do the passthrough of the whole Nvidia PCI Express 3.0 that has an HDMI / audio connector that I can use.


----------



## ziomario (Aug 7, 2021)

Geezer said:


> View attachment 10894
> 
> For your reference:
> `BHYVE_FLAGS="    \
> ...



can u tell me how you have configured the network interface tap0 and the bridge necessary to make bhyve work ?


----------



## cmoerz (Aug 7, 2021)

I read through those logs on Github as well as in your previous posts; you're trying to connect as root. I believe this will not work, unless you updated your /usr/local/etc/xrdp/sesman.ini beforehand (see *AllowRootLogin* value). I can't tell from the logs whether you already fixed that.

If you don't want to wade through freerdp's man page to set username, password et al, I can highly recommend net/remmina - even though it probably comes with a bunch of gnome related dependencies. So I won't blame you for not wanting that.

Either way, I'd recommend connecting to a user account that already exists on your debian vm, or one you created for remote use.


----------



## ziomario (Aug 7, 2021)

I wanted to know what's your detailed configuration for bhyve regarding the network interface. As I've told,I'm not able to use bhyve,but only vm-bhyve. The problem I have is that if I use bhyve,then the virtual machine is not able to connect to internet. I've tried remmina. It didn't work. You can go here if u want to see the error that I get and that I haven't been able to fix yet : https://www.reddit.com/r/Remmina/comments/ozf73g/cant_startconnect_to_pulseaudio_using_remmina_on/. I know that I have opened this thread to fix the pulse audio problem and its not right to use it to fix another problem,so you can give a look at the thread that I have opened some time ago,where I have explained the problem,that at today hasn't been fixed yet. Here : https://forums.freebsd.org/threads/...or-network-unreachable-n-2.81340/#post-524571


----------



## ziomario (Aug 8, 2021)

I've installed remmina on FreeBSD 13 and the xrdp server on Ubuntu 21.04. This is the guide that I have read :

https://github.com/neutrinolabs/pulseaudio-module-xrdp

the  installation and configuration of the modules went good,I didn't see any error. At the end of the guide,he says : "To see if it works, run pavumeter in the xrdp session. Playback any YouTube video in Firefox. You'll see "Showing signal levels of *xrdp sink*" and volume meter moving.

I've issued some commands on the terminal and I saw that the sound levels are moving. Anyway,I don't hear any sound from youtube videos.


----------



## cmoerz (Aug 10, 2021)

Alright, you're one step further. I see you got the RDP connection working now. The neutrinolabs plugin actually is required only if you intend to do recording in the VM as well. Apologies for that, I mentioned that only in a later post.

Anyways, I suspect that your issue might now lie within your host, not in the vm. For the local playback to work, you'll likely need pulseaudio to run in your host as well. Otherwise, remmina will not be able to play back any sound. Did you already run something like `pgrep pulseaudio` (or even better: `pactl info`) to check whether pulseaudio is running?


----------



## ziomario (Aug 10, 2021)

can u satisfy my curiosity ? remmina (or whatever) does need that I run bhyve with the parameter that "take" the audio from the host and that "put" it inside the virtual machine ? I ask this because with qemu the audio should be configured adding some parameters to qemu itself.

anyway : from freebsd host :


```
marietto@marietto:~ $  pactl info

Stringa server: /var/run/user/1001/pulse/native
Versione protocollo libreria: 34
Versione protocollo server: 34
Locale: sì
Indice client: 11
Dimensione tile: 65472
Nome utente: marietto
Nome host: marietto
Nome server: pulseaudio
Versione server: 14.2
Specifica di campionamento predefinita: s16le ch 2 44100 Hz
Mappa del canale predefinita: front-left,front-right
Sink predefinito: oss_output.dsp8
Sorgente predefinita: oss_input.dsp8
Cookie: e95d:2589
```

Infact as u can see,my bhyve config file does not include any audio setting :


```
loader="uefi"
cpu=8
memory=8GB
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="ubuntu-budgie-gpu.img"
uuid="ca6be87e-eed2-11eb-abbb-e0d55ee21f22"
network0_mac="58:9c:fc:0a:b1:92"
graphics="yes"
graphics_res="1440x900"
xhci_mouse="yes"
```


----------



## cmoerz (Aug 11, 2021)

Well, in principle, you have some virtual audio emulation in xrdp that plays audio (and with the neutrinolabs plugin supposedly is also able to record) in your debian VM. So, you should actually be running the opposite way - with playback to "Local" on your host, playing back the audio from your guest VM. You would not need any bhyve options for that, because you're not using any emulated audio hardware but the virtual RDP audio channel in the VM.

The `pactl` output tells me that pulseaudio seems to be fine in your host. If I were you, I'd try without the neutrinoplugin in debian, if that still fails to play.
I suppose, you did confirm before, that local playback (i.e. playing some music via VLC or a Youtube video in Firefox) in your FreeBSD host already works? So I'm assuming that, with the right remmina settings, this has got to work.

In the end, the setup should look something like this:

```
freebsd --remina/RDP------> xrdp | debian (bhyve)
     audio playback:
     local
```


----------



## ziomario (Aug 11, 2021)

maybe I found the reason why it does not work. In the remmina client I should fill the value for "redirect the local audio ouput" but I don't know which value should I put there.


----------



## cmoerz (Aug 11, 2021)

That's empty on my end and it works fine without setting that.


----------



## ziomario (Aug 11, 2021)

If I keep it empty,inside the linux vm I see the message : establishing connection to pulseaudio and nothing happens.


----------



## ziomario (Aug 11, 2021)

I've installed anydesk on FreeBSD and on Ubuntu / vm-bhyve. On the anydesk that run on FreeBSD I've configured the audio like this :

transmissions :

v : enable audio transmissions
-specify device =  /dev/dsp8

output :

v : enable playback
-playback device = /dev/dsp0

But I'm not sure what device is correct for transmissions and playback. I'm not able to understand how to detect what are the correct devices. In Linux I see "dummy output",so there is something that don't work.


----------



## cmoerz (Aug 12, 2021)

When you play back a Youtube video in Firefox on your host, you can use `pavucontrol` to switch between the outputs. Alternatively, you can use audio/audacity to play back a sound file to the different dsp devices.

As a matter of fact. You can even just
`cat /dev/rc.conf > /etc/dsp0` 
and you should hear some sound coming on whatever output channel you are catting into. 

Check your /dev/dsp* files, which dsp devices you have available or do a `cat /dev/sndstat`.

This should help you understand, what dsp0..8 is what. Usually, there's different devices for speaker, headphone jack, and so on. You can use `mixer` to adjust volume and input levels.


----------



## ziomario (Aug 12, 2021)

maybe u meant "cat /etc/rc.conf > /dev/dsp0 ?

good. I hear some noise from /dev/dsp and dsp8.0 ; dsp 8.1 ;

root@marietto:/mnt/da0p1/vms # ls /dev/dsp*

/dev/dsp0.0    /dev/dsp11.0    /dev/dsp4.0    /dev/dsp7.0    /dev/dsp9.0
/dev/dsp1.0    /dev/dsp2.0    /dev/dsp5.0    /dev/dsp8.0
/dev/dsp10.0    /dev/dsp3.0    /dev/dsp6.0    /dev/dsp8.1

root@marietto:/mnt/da0p1/vms # cat /dev/sndstat

Installed devices:
pcm0: <NVIDIA (0x0091) (HDMI/DP 8ch)> (play)
pcm1: <NVIDIA (0x0091) (HDMI/DP 8ch)> (play)
pcm2: <NVIDIA (0x0091) (HDMI/DP 8ch)> (play)
pcm3: <NVIDIA (0x0091) (HDMI/DP 8ch)> (play)
pcm4: <NVIDIA (0x0084) (HDMI/DP 8ch)> (play)
pcm5: <NVIDIA (0x0084) (HDMI/DP 8ch)> (play)
pcm6: <NVIDIA (0x0084) (HDMI/DP 8ch)> (play)
pcm7: <NVIDIA (0x0084) (HDMI/DP 8ch)> (play)
pcm8: <Realtek ALC1220 (Rear Analog 5.1/2.0)> (play/rec) default
pcm9: <Realtek ALC1220 (Front Analog)> (play/rec)
pcm10: <Realtek ALC1220 (Rear Digital)> (play)
pcm11: <Intel Kaby Lake (HDMI/DP 8ch)> (play)
No devices installed from userspace.

So,this is not wrong :

transmissions :

v : enable audio transmissions
-specify device =  /dev/dsp8


----------

