FDH2 / UxPlay

AirPlay Unix mirroring server
GNU General Public License v3.0
1.35k stars 72 forks source link

avahi-daemon is started but uxplay stalls at "Initialized server socket(s)" #41

Closed giacomoarienti closed 2 years ago

giacomoarienti commented 2 years ago

OS: Ubuntu 21.10 Uxplay version: UxPlay 1.44 Avahi-Deamon version: avahi-daemon 0.8 Avahi-Deamon service status: active (running)

giacomoarienti commented 2 years ago

Uxplay output:

using system MAC address xx:xx:xx:xx:xx:xx
Initialized server socket(s)
fduncanh commented 2 years ago

If you (EDIT) CAN see the server listed on the client, you probably have a firewall running. See troubleshooting in README

giacomoarienti commented 2 years ago

If you XXXXX see the server listed on the client, you probably have a firewall running. See troubleshooting in README EDIT: CAN both iptables and ufw are disabled

fduncanh commented 2 years ago

check that you don't also have firewalld running. Some other user kept on insisting he didnt have a firewall because he had shut down ufw, but he also was running firewald without knowing it.

systemctl status firewalld

fduncanh commented 2 years ago

see closed issue #8

fduncanh commented 2 years ago

If you can see the server uxplay@.... listed on the iPad/iPhone its a firewall issue

If you cannot see the server listed on the client, its an avahi issue.

giacomoarienti commented 2 years ago

I've added the following rules to ufw:

7000,7001,7100/tcp         ALLOW       Anywhere                  
6000,6001,7011/udp         ALLOW       Anywhere                  
7000,7001,7100/tcp (v6)    ALLOW       Anywhere (v6)             
6000,6001,7011/udp (v6)    ALLOW       Anywhere (v6)             

7000,7001,7100/tcp         ALLOW OUT   Anywhere                  
6000,6001,7011/udp         ALLOW OUT   Anywhere                  
7000,7001,7100/tcp (v6)    ALLOW OUT   Anywhere (v6)             
6000,6001,7011/udp (v6)    ALLOW OUT   Anywhere (v6)

I've also checked and firewalld, firewall-cmd and iptables services are not present, but I still have the same issue. I've tried to reinstall avahi-daemon using the following command: sudo apt-get install -y avahi-daemon and recompile the executable but with no success.

P.S. I can't see the server on the client.

fduncanh commented 2 years ago

@giacomoarienti

P.S. I can't see the server on the client.

This means that it is NOT a firewall issue, it is an avahi issue.

You seem to have a running avahi-daemon (check with

sudo systemctl status avahi-daemon

Try to start your iPad or iPhone searching for an Airplay server, and then start uxplay while it is searching.

giacomoarienti commented 2 years ago

@fduncanh

Avahi is running but I still can't see the server on the client

systemctl is-active avahi-daemon.service
active
giacomoarienti commented 2 years ago

Also If I try to start uxplay as root I get the following error: error: XDG_RUNTIME_DIR not set in the environment.

fduncanh commented 2 years ago

this seems similar to your issue https://stackoverflow.com/questions/58317665/error-xdg-runtime-dir-not-set-in-the-environment

fduncanh commented 2 years ago

I tested on Ubuntu 21.10 in a virtualbox I saw that autovideosink selected the OpenGL window manager instead of X try uxplay -vs xvimagesink (or ximagesink)

fduncanh commented 2 years ago

In recent UxPlay the start of the video renderer is moved to before the start of he RAOP server, so it fails, I guess you wont get as fair as registering with avahi. EDIT: this is wrong, you did get to the avahi registration because of the "..sockets(s).." message.

Ill add some terminal output to indicate what is happening to help in troubleshooting

fduncanh commented 2 years ago

I added a test (in the git master latest uxplay, not the release) that gives an error message if the GStreamer video renderer does not initialize properly. You could try again with a fresh download of the code from github.

The message "Initialized Server Sockets(s)" comes after the server starts, just before registering the AirPlay service with Avahi, so I dont think a GStreamer issue would block Avahi unless uxplay crashed, but I might be wrong.

fduncanh commented 2 years ago

To check for GStreamer problems this environment variable is useful

export GST_DEBUG=2

fduncanh commented 2 years ago

tested on a native (not virtualbox) default new (minimal) installation of ubuntu-20.10 on its own partition. (X86_64 desktop with nvdia graphics (nouveau driver), Xwayland seems to be used by default.)

UxPlay behaved perfectly. Avahi was automatically working without my doing anything. No firewall was active in this new installation.

The client and server have to be on same local network for avahi to work.

fduncanh commented 2 years ago

Start the client looking for a server, THEN start uxplay.

giacomoarienti commented 2 years ago

I started the client first, I made sure that avahi service was started, ufw was already set and that I were on the same network, but I didn't manage to see the server on the client.

fduncanh commented 2 years ago

When you pull down the "screen mirroring" box on the iOS client (e.g. an iPad), it sends a "Bonjour" dns-sd request for AirPlay service to the local network.

If Avahi running on the server hosting uxplay (or on another dns-sd server that has registered uxplay's offer to provide service) hears it, it will broadcast the AirPlay service address of uxplay to the network.

The client will hear this and show the AirPlay server name in the "screen mirroring box".

When the user then selects uxplay on the client, the client sends a connection request to the selected server.

Nothing happens on uxplay until the connection request is received from the client. (If there is a closed firewall on the server, the client's connection request never gets through to to uxplay)

You will then see Accepted IPv4 client on socket XX in the server window where uxplay is running, and the connection process between client and server will start,

Since your client apparently never gets to learn that uxplay is providing airplay service to clients on the network, something is wrong with either your network, or your avahi service. maybe you should use some tool like netstat (on the server) to listen to the network to debug your network issue.

Is your network iPv4 or ipV6? I think uxplay currently only responds to ipV4 requests (ipV4 is addresses like 192.168.1.23)

giacomoarienti commented 2 years ago

how can I check if my network is IPV4 ? I'm pretty sure it is but UxPlays says it binds on MAC address 18:31:xx:xx:xx:xx

fduncanh commented 2 years ago

The network address is not the MAC address.

ifconfig (on the server) will show you its network address.

on the iOS device see https://www.businessinsider.com/iphone-ip-address for instructions

fduncanh commented 2 years ago

For example server 192.168.1.23 client 192.168.1.43

shows they are both ipV4 and on the same network.

giacomoarienti commented 2 years ago

server: 192.168.1.103 client: 192.168.1.120

fduncanh commented 2 years ago

OK. both on same ipv4 network.

Something is misconfigured or unusual about your network or avahi setup. Until you can send a connection request to uxplay, I cant help.

I checked with a clean install of ubuntu 21.10 on an intel desktop machine and uxplay worked "out of the box" with no need to me to configure anything. (Of course the local network was already set up)

giacomoarienti commented 2 years ago

should I try to uninstall or disable something ?

fduncanh commented 2 years ago

I have no idea what the issue is. netstat or something like it might help you understand what is (not) happening.

I don't think it is a uxplay problem. start investigating with a dns-sd browser on the iOS device https://apps.apple.com/us/app/discovery-dns-sd-browser/id305441017

giacomoarienti commented 2 years ago

seems like the iOS device doesn't detect any device on "local" domain

fduncanh commented 2 years ago

Can you server 192.168.1.103 ping your client? (On server) ping 192.168.1.120

giacomoarienti commented 2 years ago

yes

fduncanh commented 2 years ago

is your local network mnds ( ".local", avahi-based) or do you run a local dns server (e.g. dnsmasq)

fduncanh commented 2 years ago

If the client manages to see uxplay, I'm sure it will work, it's verified on ubuntu 21.10. It may be necessary to start or restart uxplay while the client is looking for airplay service (has the "screen mirroring" box open)

giacomoarienti commented 2 years ago

how can I see if I have a running local dns server ? also this is my avahi log:

dic 20 19:14:27 ubuntu avahi-daemon[967]: Network interface enumeration completed.
dic 20 19:14:27 ubuntu avahi-daemon[967]: Registering new address record for ::1 on lo.*.
dic 20 19:14:27 ubuntu avahi-daemon[967]: Registering new address record for 127.0.0.1 on lo.IPv4.
dic 20 19:14:28 ubuntu avahi-daemon[967]: Server startup complete. Host name is ubuntu.local. Local service cookie is 2223200786.
dic 20 19:14:30 ubuntu avahi-daemon[967]: Joining mDNS multicast group on interface enp0s31f6.IPv6 with address fe80::dcc5:49f3:2a>
dic 20 19:14:30 ubuntu avahi-daemon[967]: New relevant interface enp0s31f6.IPv6 for mDNS.
dic 20 19:14:30 ubuntu avahi-daemon[967]: Registering new address record for fe80::dcc5:49f3:2a2e:812f on enp0s31f6.*.
dic 20 19:14:33 ubuntu avahi-daemon[967]: Joining mDNS multicast group on interface enp0s31f6.IPv4 with address 192.168.1.103.
dic 20 19:14:33 ubuntu avahi-daemon[967]: New relevant interface enp0s31f6.IPv4 for mDNS.
dic 20 19:14:33 ubuntu avahi-daemon[967]: Registering new address record for 192.168.1.103 on enp0s31f6.IPv4.
fduncanh commented 2 years ago

You do have some ipV6 activity fe80::dcc5....... as well as IPV4. (I dont think its a problem)

After starting uxplay run (in a different terminal window) avahi-browse -a -t to see if uxplay got registered

fduncanh commented 2 years ago
fduncanh@ubuntu21:~/Desktop$ uxplay 
using system MAC address XX:XX:XX:XX:XX
Initialized server socket(s)
fduncanh@ubuntu21:~/Desktop$ avahi-browse -a -t
+   eno1 IPv6 UxPlay@ubuntu21                               AirPlay Remote Video local
+   eno1 IPv4 UxPlay@ubuntu21                               AirPlay Remote Video local
+     lo IPv4 UxPlay@ubuntu21                               AirPlay Remote Video local
+   eno1 IPv6 XXXXXXXXXXXX@UxPlay@ubuntu21                  AirTunes Remote Audio local
+   eno1 IPv4 XXXXXXXXXXXX@UxPlay@ubuntu21                  AirTunes Remote Audio local
+     lo IPv4 XXXXXXXXXXXX@UxPlay@ubuntu21                  AirTunes Remote Audio local
<snip>
giacomoarienti commented 2 years ago
+ vboxnet0 IPv6 UxPlay@ubuntu                                 AirPlay Remote Video local
+ vboxnet0 IPv4 UxPlay@ubuntu                                 AirPlay Remote Video local
+ enp0s31f6 IPv6 UxPlay@ubuntu                                 AirPlay Remote Video local
+ enp0s31f6 IPv4 UxPlay@ubuntu                                 AirPlay Remote Video local
+     lo IPv4 UxPlay@ubuntu                                 AirPlay Remote Video local
+ vboxnet0 IPv6 1831BF511FFE@UxPlay@ubuntu                    AirTunes Remote Audio local
+ vboxnet0 IPv4 1831BF511FFE@UxPlay@ubuntu                    AirTunes Remote Audio local
+ enp0s31f6 IPv6 1831BF511FFE@UxPlay@ubuntu                    AirTunes Remote Audio local
+ enp0s31f6 IPv4 1831BF511FFE@UxPlay@ubuntu                    AirTunes Remote Audio local
+     lo IPv4 1831BF511FFE@UxPlay@ubuntu                    AirTunes Remote Audio local
giacomoarienti commented 2 years ago

At this point I think is a problem of my iOS device ? How can I check for it ?

fduncanh commented 2 years ago

try with a different iOS device if you can borrow one.

What is the device you are using? iPad or iPhone, which generation? what version of iOS does it run? Something really old might not work, but iOS 9 will at least partially, maybe fully, work, and anything running iOS 12 or newer definitely works. Current is iOS 15.2. But failures due to old iOS would happen after the connection is made, and your device does not seem to be able to see the AirPlay/AirTunes service. (It's actually the AirTunes service that gets used for making the connection),

giacomoarienti commented 2 years ago

Iphone Xs OS: 15.0.2

fduncanh commented 2 years ago

Should be good.

Its more likely to be some network or avahi problem, but testing with a different iOS device is the easiest thing to do to rule out some issue with the iPhone.

fduncanh commented 2 years ago

what should happen is:

  1. the iPhone broadcasts a request to the network looking for AirPlay service. 2 a. Some DNS-SD server on the network which has registered UxPlay service broadcasts a reply giving the address of the service. 2 b. Any other DNS-SD servers which did not yet respond about UxPlay hear the first response, so do nothing.
  2. The client hears the response(s) and displays the list of service-providers that it has heard about.

one of these steps is apparently failing.

https://support.apple.com/en-us/HT204289

Note: UxPlay does not require the code mentioned in Apples support page.

Also check the AirPlay settings on the iPhone, I dont think they can block AirPlay, but check.

If you solve your problem, post the solution here.

giacomoarienti commented 2 years ago

also tested on another iOS device but the server doesn't show up

fduncanh commented 2 years ago

good, now you know its some kind of network problem (or avahi) problem.

But I test installed debian 21.10 (with a functioning network) and avahi just worked without any configuration needed, so I think its some network issue.

giacomoarienti commented 2 years ago

If I add the -D option to avahi-browse that should -D Browse for browsing domains instead of services I get no results:

avahi-browse -a -D -t
+  n/a  n/a .
fduncanh commented 2 years ago

I see services with avahi-browse-a -t but nothing when I add -D, so this may be normal.

fduncanh commented 2 years ago
       -D | --browse-domains
              Browse for browsing domains instead for services. avahi-browse-domains is equivalent to avahi-browse --browse-domains

       -d | --domain= DOMAIN
              Browse in the specified domain. If omitted avahi-browse will browse in the default browsing domain (usually .local)
giacomoarienti commented 2 years ago

I also tried to reset my router to factory settings but that didn't help

fduncanh commented 2 years ago

network problems are tricky.

netstat from net-tools package might give you some clues

fduncanh commented 2 years ago

but netstat is more useful after the connection is made, I dont know if it will hear the client before then

fduncanh commented 2 years ago

can the iphone see things like printers on the network? (assuming they support BonJour protocol)

giacomoarienti commented 2 years ago

I have nothing to test airplay on