P
P
Pavel Shvedov2014-08-26 20:48:41
JavaScript
Pavel Shvedov, 2014-08-26 20:48:41

How to make a SIP call using Node.JS?

Hello everyone, the task is as follows: There is an application on node.js, there is an account with the SIP provider myvoiptraffic.com. It is necessary to make a call from the application to the subscriber through this provider. It is enough just to call (or get "busy" in response), then stop the call (done in order to be sure that the client took the phone in his hand). I found the sip-client module on npm. I do everything according to the instructions:

var SIPClient = require('sip-client');
var util = require('util');

// I suppose these are pretty self explanatory
var opts = {
  user: 'YYYYYYYYYY', // логин пользователя на myvoiptraffic.com
  password: 'QWERTYQWERTY', // пароль пользователя
  host: 'sip.myvoiptraffic.com',
  debug: true //unless you want to see HARDCORE SIP ACTION!
};

var client = new SIPClient(opts);

var uri = {
  schema: 'sip',
  host: opts.host,
  user: opts.user
};
var headers = {
  contact: "<sip:"+opts.host+":5060>",
  from: {
    name: '<sip:[email protected]>',
    uri: uri
  },
  to: {
    name: '<sip:[email protected]>',
    uri: uri
  }
};

var message = client.message('register', {host: opts.host}, headers);
message.send();

message.on('success', function(msg) {
  client.on('invite', function(msg){
    var from = client.sip.parseUri(msg.headers.from.uri);
    util.log("The most handsome dude(ette), "+from.name+" at "+from.user);
  });
});

crashes on connection timeout:
bash-3.2$ node .
> REGISTER sip:sip.myvoiptraffic.com SIP/2.0
> contact: <sip:sip.myvoiptraffic.com:5060>
> From: <sip:[email protected]> <sip:[email protected]>
> To: <sip:[email protected]> <sip:[email protected]>
> call-id: 11b677-1e00e7-1eb415-18569c
> Via: SIP/2.0/TCP sip.myvoiptraffic.com
> CSeq: 1 REGISTER
> content-length: 0
> 
> 

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: connect ETIMEDOUT
    at errnoException (net.js:904:11)
    at Object.afterConnect [as oncomplete] (net.js:895:19)

A module of very dubious quality, it is not known if it ever worked. Has anyone encountered a similar issue by any chance? Maybe there are some ideas?
P.S. In the code and in the log, the user's login is everywhere replaced by YYYYYYYYYY, the subscriber's number by XXXXXXXXXXXXXX and the user's password by QWERTYQWERTY. Naturally, the code uses real values, using which we managed to successfully call through the Linphone cell phone

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Likhachev, 2014-08-27
@mmmaaak

try baresip

X
xanm, 2015-07-13
@xanm

baresip https://github.com/alfredh/baresip
+
node_baresip https://github.com/AlexMarlo/node_baresip

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question