elcuervo / airplay

Airplay bindings to Ruby
MIT License
1.07k stars 69 forks source link

`air list` causes "ERROR persistent: Net::PTTH crashed!" #77

Open C-Duv opened 10 years ago

C-Duv commented 10 years ago

On a freshly installed Debian VM I can't get to list AirPlay devices as I get:

ERROR persistent: Net::PTTH crashed! SocketError: getaddrinfo: Name or service not known

Is there something trivially forgotten when running airplay on a fresh Debian install?

Here is full output:

root@debian:~# air list
ERROR persistent: Net::PTTH crashed!
SocketError: getaddrinfo: Name or service not known
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `initialize'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `new'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `raw_socket'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:16:in `write'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth.rb:78:in `request'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'
ERROR persistent: Net::PTTH crashed!
SocketError: getaddrinfo: Name or service not known
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `initialize'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `new'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `raw_socket'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:16:in `write'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth.rb:78:in `request'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'
ERROR persistent: Airplay::Connection crashed!
SocketError: getaddrinfo: Name or service not known
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `initialize'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `new'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `raw_socket'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:16:in `write'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth.rb:78:in `request'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'
        (celluloid):0:in `remote procedure call'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:92:in `value'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/proxies/sync_proxy.rb:33:in `method_missing'
        /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/connection/persistent.rb:39:in `request'
        /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/connection.rb:113:in `send_request'
        /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/connection.rb:80:in `get'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'
ERROR persistent: Airplay::Connection crashed!
SocketError: getaddrinfo: Name or service not known
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `initialize'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `new'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `raw_socket'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:16:in `write'
        /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth.rb:78:in `request'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'
        (celluloid):0:in `remote procedure call'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:92:in `value'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/proxies/sync_proxy.rb:33:in `method_missing'
        /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/connection/persistent.rb:39:in `request'
        /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/connection.rb:113:in `send_request'
        /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/connection.rb:80:in `get'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in `dispatch'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
        /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'
/var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `initialize': getaddrinfo: Name or service not known (SocketError)
        from /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `new'
        from /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:47:in `raw_socket'
        from /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth/socket.rb:16:in `write'
        from /var/lib/gems/1.9.1/gems/net-ptth-0.0.17/lib/net/ptth.rb:78:in `request'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in `dispatch'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'
        from (celluloid):0:in `remote procedure call'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:92:in `value'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/proxies/sync_proxy.rb:33:in `method_missing'
        from /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/connection/persistent.rb:39:in `request'
        from /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/connection.rb:113:in `send_request'
        from /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/connection.rb:80:in `get'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in `dispatch'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'
        from (celluloid):0:in `remote procedure call'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:92:in `value'
        from /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/proxies/sync_proxy.rb:33:in `method_missing'
        from /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/device.rb:125:in `basic_info'
        from /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/device.rb:86:in `server_info'
        from /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/device/info.rb:12:in `initialize'
        from /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/device.rb:78:in `new'
        from /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/device.rb:78:in `info'
        from /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/cli.rb:48:in `block in list'
        from /var/lib/gems/1.9.1/gems/airplay-1.0.2/lib/airplay/cli.rb:46:in `list'
        from /var/lib/gems/1.9.1/gems/clap-1.0.0/lib/clap.rb:35:in `call'
        from /var/lib/gems/1.9.1/gems/clap-1.0.0/lib/clap.rb:35:in `run'
        from /var/lib/gems/1.9.1/gems/clap-1.0.0/lib/clap.rb:6:in `run'
        from /var/lib/gems/1.9.1/gems/airplay-cli-1.0.1/bin/air:8:in `<top (required)>'
        from /usr/local/bin/air:23:in `load'
        from /usr/local/bin/air:23:in `<main>'

Versions used: ruby v1.9.3p194 airplay gem v1.0.2, 0.2.9 airplay-cli gem v1.0.1 net-ptth gem v0.0.17 Debian v7.3

elcuervo commented 10 years ago

It should work without issues but I can see where it could be failing. Can you please install dns-sd and run dns-sd -Z _airplay._tcp to see what it's being broadcasted?

C-Duv commented 10 years ago

Couldn't find a gem named dns-sd (nor a Debian package) but if you refer to MOX/Darwin's dns-sd I might have found the GNU/Linux equivalent: avahi-browse from avahi-utils:

root@debian:~# avahi-browse _airplay._tcp
+   eth0 IPv6 atv                                           _airplay._tcp        local
+   eth0 IPv4 atv                                           _airplay._tcp        local
^CGot SIGINT, quitting.
root@debian:~#

atv is indeed the network name of my AppleTV (FQDN is atv.domicile.local).

jonahoffline commented 10 years ago

@C-Duv I've seen this happen with other libraries before as a result of:

So check those two files just to be safe. You could try replacing your current dns settings with Google DNS or Open DNS for your /etc/resolv.conf

Finally, you could try opening an irb or pry session and running this code:

require 'net/http'

Socket.getaddrinfo('www.youtube.com', 'http')

If all is good you will get a bunch of arrays with ip addresses. This means your computer was probably possessed for that moment and couldn't resolve the name to its ip address. Let us know if some of this helped, thanks :cat:

C-Duv commented 10 years ago

Had no wildcards in /etc/hosts, put 8.8.8.8 in /etc/resolv.conf and got arrays of IP with given code... However, installed ruby, ruby-dev, avahi-daemon, avahi-utils, libavahi-compat-libdnssd1, libavahi-compat-libdnssd-dev on a non-VM Debian 7.3 and got air list (+air play and air view) running at first try.

Problem is not really solved but since my goal was to first try on the VM before installing it on the production server... I'm fine.

I'm gonna compare installed package list of both Debian and try to find a explanation...

elcuervo commented 10 years ago

Thank you for the feedback @C-Duv! :fist: . I'll add some of this information to the README

C-Duv commented 10 years ago

First really quick analysis shows that:

root@debian-NOTWORKING:~# gem list | grep -e air -e net-ptth
airplay (1.0.2, 0.2.9)
airplay-cli (1.0.1)
airstream (0.4.4)
net-ptth (0.0.17)
root@debian-WORKING:~# gem list | grep -e air -e net-ptth
airplay (1.0.2)
airplay-cli (1.0.1)
net-ptth (0.0.17)

It is true that I had stumbled upon airstream gem (before airplay), and installed. It seems to have (on the not working server) required an older version of airplay: 0.2.9. Uninstalling the 0.2.9 and keeping 1.0.2 didn't solved the problem though.

C-Duv commented 10 years ago

Sorry but I couldn't narrow down the problem. I did had the following packages installed on not-working server but absent of working server:

arda2012 commented 10 years ago

I had exactly this problem today. After adding some debugging prints, I have found that .local seems to be appended to the found device. So in your example the problem could possibly be resolved either by adding atv.local to /etc/hosts or even better by installing the nss-mdns4 module and changing the line "hosts: files dns" to "hosts: files mdns4_minimal dns" /etc/nsswitch.conf.

C-Duv commented 10 years ago

To confirm @arda2012's comment, here is the content of my /etc/nsswitch.conf file: Non-working: hosts: files dns Working box : hosts: files dns mdns mdns4_minimal [NOTFOUND=return] mdns4

The lack of mdns* seems to be the cause. I've changed hosts line to hosts: files mdns dns and air list worked right away afterwards.

kaikuehne commented 10 years ago

Hi. I wanted to try out airplay.rb today and I've added those lines to the /etc/nsswitch.conf file but still get the same error stated above. Can I try something else? Thanks.

priezz commented 9 years ago

The problem is that local (not global) domains could not be resolved. To enable is in Arch Linux nss-mdns package is required. In Debian there should be something similar (rdnssd, I assume).

varac commented 7 years ago

Same error on ubuntu 16.04.

Local Domain is resolvable, and airplay service is found vy avahi:

--- airplay/airplayer ‹master* ⁇› » ping osmc.local
PING osmc.local (192.168.8.8) 56(84) bytes of data.
64 bytes from osmc (192.168.8.8): icmp_seq=1 ttl=64 time=2.64 ms
^C
--- osmc.local ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.643/2.643/2.643/0.000 ms

--- airplay/airplayer ‹master* ⁇› » avahi-browse _airplay._tcp
+  wlan0 IPv4 osmc                                          _airplay._tcp        local

What else can i try ?