Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in debug method on content-length: 0 #39

Open
jaredwhite128 opened this issue Dec 20, 2015 · 3 comments
Open

Crash in debug method on content-length: 0 #39

jaredwhite128 opened this issue Dec 20, 2015 · 3 comments

Comments

@jaredwhite128
Copy link

The debug method on line 233 of rtspmethods.js seems to assume too much about a general request object:

debug('uncaptured SET_PARAMETER method: %s', req.content.toString().trim());

iTunes on iOS 9.2 issued the following request when streaming a file with no accompanying artwork:

received method SET_PARAMETER (CSeq: 6)
{ 'rtp-info': 'rtptime=839107797',
  'content-length': '0',
  'content-type': 'image/none',
  cseq: '6',
  'dacp-id': '___redacted___',
  'active-remote': '___redacted___',
  'user-agent': 'AirPlay/267.3' }

I believe the zero-length content led req.content to be undefined, giving the following error while formatting the debug message:

TypeError: Cannot read property 'toString' of undefined

The following fix worked, but may not be the detailed logging message originally intended:

debug('uncaptured SET_PARAMETER method: %s', req.getHeader('Content-Type'));

Thanks for looking at this issue, and thanks also for this excellent software.

@jaredwhite128
Copy link
Author

Here were the versions I am using, from npm version:

{ airsonos: '0.2.5',
  npm: '3.3.12',
  ares: '1.10.1-DEV',
  http_parser: '2.6.0',
  icu: '56.1',
  modules: '47',
  node: '5.3.0',
  openssl: '1.0.2e',
  uv: '1.8.0',
  v8: '4.6.85.31',
  zlib: '1.2.8' }

@Sinaloit
Copy link

I would suggest changing

debug('uncaptured SET_PARAMETER method: %s', req.content.toString().trim());

to:

 var debugString;
 if ("content" in req) {
   debugString = req.content.toString().trim();
 } else {
   debugString = req.getHeader('Content-Type');
 }
 debug('uncaptured SET_PARAMETER method: %s', debugString);

or something similar to capture both cases when you have content and when you do not. I can confirm this prevents airsonos from crashing out when it receives a stream with no image associated. My test case was going to tribeofnoise and playing a clip off the page (from safari) and sending to airplay.

@ghost
Copy link

ghost commented May 11, 2016

This worked for me. Thanks Sinaloit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants