Answer the question
In order to leave comments, you need to log in
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);
});
});
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)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question