kirm / sip.js

Session Initiation Protocol for node.js
MIT License
431 stars 171 forks source link

sip.js:540 if(m.headers['content-length']) { TypeError: Cannot read property 'headers' of undefined #7

Closed andrewhodel closed 12 years ago

andrewhodel commented 12 years ago

I get this when trying to run examples/registrar-redirector-auth.js on 0.6.5 using http://itunes.apple.com/us/app/telephone/id406825478?mt=12 as a SIP client.

sip.js:540 if(m.headers['content-length']) { ^ TypeError: Cannot read property 'headers' of undefined at parseMessage (/home/zip/node_modules/sip/sip.js:540:9) at Socket. (/home/zip/node_modules/sip/sip.js:633:15) at Socket.emit (events.js:70:17) at UDP.onMessage as onmessage

andrewhodel commented 12 years ago

I've done some more testing on this, I was going to tag it with "node-compatibility" but this error persists on node v0.4.13-pre using the same SIP client (OS X Telephone).

I will update back once I do some more testing with different sip clients.

andrewhodel commented 12 years ago

Just tested with:

'user-agent': 'Asterisk PBX 1.6.2.21'

and it works fine, must be some sort of weird data the OS X Telephone app is sending. Nonetheless it shouldn't be able to crash the entire program!

andrewhodel commented 12 years ago

Here's a wireshark/tcpdump showing what's going on: http://cobianet.com/telephone_osx_sipjs_tcpdump

You'll see the 5th packet in the tcpdump is being sent to sip.js on port 5060. However, the data in this packet is only 2 bytes: 0d0a

It's quite obvious that it's the Telephone app for OS X causing this, but nonetheless it shouldn't be able to crash the server.

kirm commented 12 years ago

Try commit 9a4b6e5499892ad320b9e159e538ec2f08b1e723.

andrewhodel commented 12 years ago

That fixed the problem, confirmed for .4.x and .6.x

Thanks!

If you ever need to integrate radius with SIP, check out https://github.com/cobianet/node-radius

/closing