stephen / nodetunes

AirTunes v2 Server implementation
214 stars 64 forks source link

rtsp.js doesn't correctly handle some SETUP requests #7

Closed danburke closed 10 years ago

danburke commented 10 years ago

Using Airsonos I saw a SETUP request hit RtspServer.connectHandler which had a leading carriage return

SETUP rtsp://192.168.1.27/4932615128151379837 RTSP/1.0
Transport: RTP/AVP/UDP;unicast;mode=record;timing_port=52230;x-events;control_port=55038
CSeq: 3
X-Apple-Device-ID: 0x4db5642d294
DACP-ID: <snip>
Active-Remote: <snip>
User-Agent: AirPlay/200.54

This caused this error

this.methodMappingm.method;
^
TypeError: Property '
SETUP' of object # is not a function
at RtspServer.connectHandler (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/rtsp.js:41:33)
at EventEmitter.emit (events.js:95:17)
at Socket.Parser (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/httplike/index.js:61:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket. (stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
danburke commented 10 years ago

I've no idea if this is the right place to handle this but it seems to fix the issue

stephen commented 10 years ago

Do you steps to repro the problem consistently? This is something I've seen from time to time as well, but I've not been able to track down why it happens.

Agree that this is a way to solve this, but I'm worried this is an issue with the underlying package used to parse the RTSP protocol (https://github.com/stephen/httplike).

I'm going to keep this open for now - see if I can track down the root cause for the extra \r.

Any input is appreciated :smile:

stephen commented 10 years ago

Thanks for tracking this down. I've fixed this in the underlying httplike implementation (adding trim()) as of version 0.0.12.