watson/airplayer

Error: Unexpected response to PTTH/1.0 Upgrade request

Opened this issue ยท 8 comments

Hi,

I'm getting this error while trying to use airplayer from the command line:

$ airplayer totally-legal-movie.mkv 
(node:32405) DeprecationWarning: Using Buffer without `new` will soon stop working. Use `new Buffer()`, or preferably `Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: Unexpected response to PTTH/1.0 Upgrade request
    at /usr/local/lib/node_modules/airplayer/node_modules/reverse-http/index.js:50:32
    at /usr/local/lib/node_modules/airplayer/node_modules/consume-http-header/index.js:12:5
    at done (/usr/local/lib/node_modules/airplayer/node_modules/consume-until/index.js:52:5)
    at Socket.consume (/usr/local/lib/node_modules/airplayer/node_modules/consume-until/index.js:33:7)
    at Socket.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:185:7)
    at emitReadable_ (_stream_readable.js:432:10)
    at emitReadable (_stream_readable.js:426:7)
    at readableAddChunk (_stream_readable.js:187:13)

More info:

$ node --version
v7.0.0
$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.11.1
BuildVersion:	15B42

If I can help please let me know.

Thanks,
Juan

hmm.. I should have mentioned I'm trying to stream to kodi..


==> /storage/.kodi/temp/kodi.log <==
12:44:11 240348.109375 T:1809122368  NOTICE: Thread GUIDialogCache start, auto delete: true
12:44:11 240348.125000 T:1967890432   ERROR: CCurlFile::Stat - Failed: Couldn't connect to server(7) for http://192.168.105.251:56690/stream.m4v|User-Agent=AppleCoreMedia%2f1.0.0.8F455%20(AppleTV%3b%20U%3b%20CPU%20OS%204_3%20like%20Mac%20OS%20X%3b%20de_de)
12:44:11 240348.203125 T:1967890432  NOTICE: DVDPlayer: Opening: http://192.168.105.251:56690/stream.m4v|User-Agent=AppleCoreMedia%2f1.0.0.8F455%20(AppleTV%3b%20U%3b%20CPU%20OS%204_3%20like%20Mac%20OS%20X%3b%20de_de)
12:44:11 240348.203125 T:1967890432 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
12:44:11 240348.203125 T:1809122368  NOTICE: Thread DVDPlayer start, auto delete: false
12:44:11 240348.203125 T:1809122368  NOTICE: Creating InputStream
12:44:11 240348.203125 T:1809122368   ERROR: CCurlFile::Stat - Failed: Couldn't connect to server(7) for http://192.168.105.251:56690/stream.m4v|User-Agent=AppleCoreMedia%2f1.0.0.8F455%20(AppleTV%3b%20U%3b%20CPU%20OS%204_3%20like%20Mac%20OS%20X%3b%20de_de)
12:44:11 240348.218750 T:1809122368   ERROR: CCurlFile::FillBuffer - Failed: Couldn't connect to server(7)
12:44:11 240348.218750 T:1809122368   ERROR: CCurlFile::Open failed with code 0 for http://192.168.105.251:56690/stream.m4v|User-Agent=AppleCoreMedia%2f1.0.0.8F455%20(AppleTV%3b%20U%3b%20CPU%20OS%204_3%20like%20Mac%20OS%20X%3b%20de_de)
12:44:11 240348.218750 T:1809122368   ERROR: Open - failed to open source <http://192.168.105.251:56690/stream.m4v|User-Agent=AppleCoreMedia%2f1.0.0.8F455%20(AppleTV%3b%20U%3b%20CPU%20OS%204_3%20like%20Mac%20OS%20X%3b%20de_de)>
12:44:11 240348.218750 T:1809122368   ERROR: CDVDPlayer::OpenInputStream - error opening [http://192.168.105.251:56690/stream.m4v|User-Agent=AppleCoreMedia%2f1.0.0.8F455%20(AppleTV%3b%20U%3b%20CPU%20OS%204_3%20like%20Mac%20OS%20X%3b%20de_de)]
12:44:11 240348.218750 T:1809122368  NOTICE: CDVDPlayer::OnExit()
12:44:11 240348.218750 T:1967890432  NOTICE: CDVDPlayer::CloseFile()
12:44:11 240348.218750 T:1967890432  NOTICE: DVDPlayer: waiting for threads to exit
12:44:11 240348.218750 T:1967890432  NOTICE: DVDPlayer: finished waiting
12:44:11 240348.218750 T:1967890432  NOTICE: CDVDPlayer::CloseFile()
12:44:11 240348.218750 T:1967890432  NOTICE: DVDPlayer: waiting for threads to exit
12:44:11 240348.218750 T:1967890432  NOTICE: DVDPlayer: finished waiting

attaching a tcp dump

POST /reverse HTTP/1.1
User-Agent: iTunes/11.0.2
Host: OpenELEC.local:36667
Upgrade: PTTH/1.0
Connection: Upgrade
Content-Length: 0

HTTP/1.1 101 Switching Protocols
Date: Sat Nov 12 12:47:57 2016
Upgrade: PTTH/1.0
Connection: Upgrade
Content-Length: 0

POST /event HTTP/1.1
Content-Type: text/x-apple-plist+xml
Content-Length: 330
x-apple-session-id: 00000000-0000-0000-0000-000000000000

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">
<dict>
<key>category</key>
<string>video</string>
<key>sessionID</key>
<integer>30</integer>
<key>state</key>
<string>loading</string>
</dict>
</plist>
POST /event HTTP/1.1
Content-Type: text/x-apple-plist+xml
Content-Length: 330
x-apple-session-id: 00000000-0000-0000-0000-000000000000

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">
<dict>
<key>category</key>
<string>video</string>
<key>sessionID</key>
<integer>30</integer>
<key>state</key>
<string>stopped</string>
</dict>
</plist>

airplay.pcapng.zip

swttt commented

Had the same issue, disabled the reverse http part.

Comment line 91 out in the index.js of airplayer-protocol (this._startReverse()). This will make it stop working on tvos for example tho.

Looks like there's a missing 'error' handler on the reverse-server instance.

I think that this is the instance that needs an 'error' handler added to it. https://github.com/watson/airplay-protocol/blob/a715752fc206ebbb8b2047573cdd81dded4970f5/index.js#L186

I haven't looked into it too deeply though, so I don't know exactly where it's appropriate to attach the handler. I bet @watson knows.

Do we have any update here?

@watson any progress on this? I'm working on an Electron app which uses Airplay, so if you need any help let me know ๐Ÿ˜‰

This app still does not work ๐Ÿ˜„