kirm / sip.js

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

Error with Buffer: [TypeError: First argument needs to be a number, array or string.] #105

Closed danielsantiago closed 8 years ago

danielsantiago commented 8 years ago

Hi,

I'm receiving the following error:

TypeError: First argument needs to be a number, array or string.
at new Buffer (buffer.js:188:15)
at decodeFlowToken (node_modules/sip/sip.js:1305:14)
at m.headers.via (node_modules/sip/sip.js:1339:24)
at Object.send (node_modules/sip/sip.js:1344:11)
at forwardRequest (node_modules/sip/proxy.js:56:7)
at Object.exports.send (node_modules/sip/proxy.js:25:23)

When receiving the following request:

RECV: { method: 'INVITE',
  uri: 'sip:+12013338404@10.230.218.217:5060',
  version: '2.0',
  headers:
   { via:
      [ { version: '2.0',
          protocol: 'UDP',
          host: '63.131.240.90',
          port: 5060,
          params:
           { branch: 'z9hG4bK+0672fc950bc4ea0bb08db22ec80852851+sip+1+aa6421b0',
             received: '63.131.240.90' } } ],
     'call-id': '0gQAAC8WAAACBAAALxYAAB4T8y+gKYwVdJep5U1N8CIn2RPRqvFHEvpgGoF99Ma/@63.131.240.90',
     from:
      { name: undefined,
        uri: 'sip:2019808743@63.131.240.90:5060',
        params: { tag: '63.131.240.90+1+7b64275d+88aab2ca' } },
     to:
      { name: undefined,
        uri: 'sip:2013338404@52.1.77.10',
        params: { tag: '78585795_6772d868_731a65ca-2947-4ef1-ab43-f572c4424feb' } },
     cseq: { seq: 490447448, method: 'INVITE' },
     expires: '180',
     route:
      [ { name: undefined,
          uri:
           { schema: 'sip',
             user: undefined,
             password: undefined,
             host: '52.1.77.10',
             port: NaN,
             params:
              { lr: null,
                ftag: '48d3350f7f10eea700a3f0607dd54d5e3dc71e9800fd5ae15e84ffcf353ef5dd' },
             headers: {} },
          params: {} },
        { name: undefined,
          uri:
           { schema: 'sip',
             user: undefined,
             password: undefined,
             host: '107.21.211.20',
             port: 5060,
             params: { lr: null, ftag: '63.131.240.90+1+7b64275d+88aab2ca' },
             headers: {} },
          params: {} } ],
     'content-length': 173,
     supported: 'resource-priority,siprec, 100rel',
     contact:
      [ { name: undefined,
          uri: 'sip:8b8d72f0e335246768328c8b799a96e5@63.131.240.90:5060',
          params: {} } ],
     'content-type': 'application/sdp',
     'allow-events': 'message-summary, refer, dialog, line-seize, presence, call-info, as-feature-event, calling-name',
     'max-forwards': '69',
     organization: 'Metaswitch Networks' },
  content: 'v=0\r\no=- 30555644139193 30555644139193 IN IP4 63.131.240.90\r\ns=-\r\nc=IN IP4 63.131.240.90\r\nt=0 0\r\nm=audio 58024 RTP/AVP 0 101\r\na=rtpmap:101 telephone-event/8000\r\na=pt$

TARGET: { protocol: 'UDP', 
  address: '63.131.240.90',
  port: 5060,
  local: { address: '0.0.0.0', port: 5060 } }

I'm using Sip.js as a Proxy and I notice that the uri host (10.230.218.217) is not my server ip, instead it's one of the legs contact host ip.

danielsantiago commented 8 years ago

The problem was that the "route" values don't have any user defined.