Giter Club home page Giter Club logo

drachtio-fsmrf's People

Contributors

byoungdale avatar davehorton avatar dependabot[bot] avatar heyphets avatar lylepratt avatar marcbachmann avatar mhertogs avatar spointer avatar two56 avatar whiteydude avatar xquanluu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drachtio-fsmrf's Issues

Error: No drachtio_mrf sip profile found on the media server

Hi,

I'm trying to deploy the drachtio-fsmrf example but the drachtio_mrf sip profile is not found. The error trace is the next:

/home/ubuntu/my-drachtio-example/node_modules/drachtio-fsmrf/lib/mediaserver.js:117
        if( null === results ) { throw new Error('No drachtio_mrf sip profile found on the media server: ' + status);}
                                 ^

Error: No drachtio_mrf sip profile found on the media server:                      Name	   Type	                                      Data	State
=================================================================================================
            external-ipv6	profile	                  sip:mod_sofia@[::1]:5080	RUNNING (0)
            174.31.10.112	  alias	                                  internal	ALIASED
                 external	profile	          sip:[email protected]:5080	RUNNING (0)
    external::example.com	gateway	                   sip:[email protected]	NOREG
            internal-ipv6	profile	                  sip:mod_sofia@[::1]:5060	RUNNING (0)
                 internal	profile	          sip:[email protected]:5060	RUNNING (0)
=================================================================================================
4 profiles 1 alias

    at MediaServer. (/home/ubuntu/my-drachtio-example/node_modules/drachtio-fsmrf/lib/mediaserver.js:117:40)
    at . (/home/ubuntu/my-drachtio-example/node_modules/modesl/lib/esl/Connection.js:141:16)
    at EventEmitter.emit (/home/ubuntu/my-drachtio-example/node_modules/eventemitter2/lib/eventemitter2.js:339:22)
    at Connection._onEvent (/home/ubuntu/my-drachtio-example/node_modules/modesl/lib/esl/Connection.js:805:10)
    at EventEmitter.emit (/home/ubuntu/my-drachtio-example/node_modules/eventemitter2/lib/eventemitter2.js:339:22)
    at Parser._parseEvent (/home/ubuntu/my-drachtio-example/node_modules/modesl/lib/esl/Parser.js:208:10)
    at Parser._parseBody (/home/ubuntu/my-drachtio-example/node_modules/modesl/lib/esl/Parser.js:100:10)
    at Parser._parseHeaders (/home/ubuntu/my-drachtio-example/node_modules/modesl/lib/esl/Parser.js:76:37)
    at Parser._parseHeaders (/home/ubuntu/my-drachtio-example/node_modules/modesl/lib/esl/Parser.js:84:37)
    at Parser._parseHeaders (/home/ubuntu/my-drachtio-example/node_modules/modesl/lib/esl/Parser.js:84:37)

I followed the readme instructions from the repository and I think the error may be in the step of setting it up as drachtio-fs-ansimbre. I do not know how to do/apply this step.

Early hangup can lead to dead endpoint with continued execution

Hi Dave!

I've come across an issue recently with the following error:

0|app | Endpoint#_onError: uuid: 0359ac03-2d61-41ec-80d7-6784fd467de1: TypeError: Cannot read property 'write' of null

Standard call flow for us is to receive an INVITE (leg A), playback various audio and receive various input, then open leg B and bridge the two together. Here's a simplified example:

https://gist.github.com/WhiteyDude/c88d77e2a3706d98abad8136d237b8d7

The TypeError above appears to be in cases where leg A has hung up somewhere within the flow, and we attempt to continue on with the flow - often during the endless_playback we substitute for ringing. As a result, the endpoint in Freeswitch is never destroyed and hangs, endlessly sending out RTP and wasting bandwidth.

Is there a way to catch the endpoint error easily? I figure from there I could simply send a uuid_kill to Freeswitch.

Thanks!

Problems playing audio into call

Hello Dave,

Me and a colleague of mine are working on an academic project that we are building based on this Drachtio and Freeswitch framework but we have been running into some problems playing audio into our call as was somewhat described here. We use containers for both of them as is suggested in several of your readmes/comments.
I decided to open a new issue with more info so that maybe we could pinpoint the problem since we have been stuck on this for a long time

We changed our app.js to be similar to what you showed us and right now it looks like this:

const Srf = require('drachtio-srf');
const srf = new Srf();
const Mrf = require('drachtio-fsmrf');
const mrf = new Mrf(srf);


srf.connect({
  "host": "127.0.0.1",
  "port": 9060,
  "secret": "cymru"
})
  .on('connect', (err, hp) => console.log(`connected to sip on ${hp}`))
  .on('error', (err) => console.log(err, 'Error connecting'));


srf.register((req, res) => {
  res.send(200);
});

srf.invite(async(req, res) => {
  try {
    const ms = await mrf.connect(
    { address:'127.0.0.1',
      port: 9070,
      secret: 'ClueCon'});
    
    const {endpoint, dialog} = await ms.connectCaller(req, res);
    console.log('Call connected');
    dialog.on('destroy', () => {
      console.log('Call ended');
      endpoint.destroy();
    });

    // await endpoint.play('/file.wav');
    await endpoint.play('http://www.music.helsinki.fi/tmt/opetus/uusmedia/esim/a2002011001-e02.wav');
    console.log('Finished playing');
  } catch (err) {
    console.log(err);
  }
});

Dockerfile:

version: '3'

networks: 
  sip-stack-drachtio:
    driver: bridge
    ipam:
      config:
        - subnet: 172.38.0.0/16

services:

  drachtio-server:
    image: drachtio/drachtio-server:latest
    command: drachtio --contact "sip:*;transport=udp" --loglevel warning --sofia-loglevel 9
    container_name: drachtio
    ports:
      - "9060:9022/tcp"
      - "5060:5060/tcp"
      - "5060:5060/udp"
    networks:
      sip-stack-drachtio:
        ipv4_address: 172.38.0.13

  freeswitch:
    image: drachtio/drachtio-freeswitch-mrf:latest
    command: freeswitch --sip-port 5060 --rtp-range-start 20000 --rtp-range-end 20040
    container_name: freeswitch
    ports:
      - "9070:8021/tcp"
      - "20000-20040:20000-20040/udp"
      - "20000-20040:20000-20040/tcp"
    
    networks:
      sip-stack-drachtio:
        ipv4_address: 172.38.0.14

package related dependencies:

"dependencies": {
    "drachtio-fn-fsmrf-sugar": "0.0.9",
    "drachtio-fsmrf": "^1.5.7",
    "drachtio-mw-registration-parser": "^0.1.0",
    "drachtio-srf": "^4.4.18"
  }

We use zoiper5 to make a call. The registration process works, the call is accepted and it hangs on silently for some time (around 30s) before printing the "Call ended" and "Finished playing" logs.

Are we doing something wrong? Could this be a container issue? We are not sure what else to test. I've considered running freeswitch locally on my machine to test but the configuration needed to set it up with drachtio is kind of scary for a newbie and deterred me.

Thank you in advance :)

Strange States on Endpoint CallStates with Bridge/Unbridge

We have hook to the event "channelCallState" on an Endpoint.

On normal operations (calling a number und Hangup) only the HangUp arrives as an event.
If you bridge 2 calls together and then call unbridge you will get within milliseconds on both endpoints?

Endpoint Stated Changed RINGING
Endpoint Stated Changed ACTIVE

Endpoint Stated Changed RINGING
Endpoint Stated Changed ACTIVE

and later (after Destroy the endpoint) a HANGUP

Handeling B leg destruction in bridge does not seem to work

Hi Dave,

I've got a bridged call and I'm trying to handle a destroy on the B leg. If B leg hangs up, I wish for A leg to be hung up also, as currently A leg just sits in silence.

Here's some example code:

                    await endpoint.bridge(b_endpoint)
                    .then(() => {
                      console.log(`Legs A and B bridged`);
                      b_dialog = setActiveBHandlers(endpoint, dialog, b_endpoint, b_dialog)
                      b_dialog.destroy()
                    });
function setActiveBHandlers(a_endpoint, a_dialog, b_endpoint, b_dialog) {
  console.log("Setting handlers due to bridge")
  b_dialog.on('destroy', () => {
    console.log("B dialog on active call destroyed, killing A too")
    if (a_dialog) a_dialog.destroy()
    if (a_endpoint) a_endpoint.destroy()
    if (b_endpoint) b_endpoint.destroy()
  })
  return b_dialog;
}

I get the "setting handlers" console message when the calls are bridged. If I log b_dialog._events.destroy it shows my function. However destroying the dialog does not seem to trigger the "B dialog on active call destroyed" console message.

In this same call, I also have an on destroy handler for the A leg set before the bridge, and this is triggered fine.

connectCaller times out with webrtc client

Currently using

app log: https://github.com/andrewvmail/drachtio-webrtc-conference/blob/master/app.log
drachtio log: https://github.com/andrewvmail/drachtio-webrtc-conference/blob/master/drachtio.log
freeswitch log: https://github.com/andrewvmail/drachtio-webrtc-conference/blob/master/freeswitch.log

connectCaller just times out, drachtio receives the invite from freeswitch but couldn't route it back to the ua, when using linphone / xlite (non webrtc) it works

Troubles trying to record the user voice

Hi Dave,

I noticed a typo at line 209 in conference.js ( [email protected] )

- assert.equals(typeof file === 'string', '\'file\' parameter must be provided') ;
+ assert.ok(typeof file === 'string', '\'file\' parameter must be provided') ;

Now, I'm having troubles trying to record the user voice for an IVR test app (with realtime audio analysis on a separate node). I'm using the recording functionalities from the drachtio-fmsrf Conference Class and the latest docker-drachtio-freeswitch-mrf image.

Is this the correct way or do you think there is a better way to record/stream the user voice (like a Freeswitch api call) ?

The problem I've comes using this fragment of code :

req.app.locals.ms.createConference('testconf', 
    (err, conf) => {
        if ( err ) {
            console.log(`error createConference: ${JSON.stringify(err)}`) ;
	    throw err ;
	}
	console.log(`conference created: ${JSON.stringify(conf)}`) ;

        // >>> local path on host, not on the docker image <<<
	conf.startRecording('/home/massimo/drachtio/recordings/record.wav',	  
	    function(err, results){
	        if ( err ) {
		    console.log(`error startRecording: ${JSON.stringify(err)}`) ;
		    throw err ;
		}
		console.log(`recording results: ${JSON.stringify(results)}`) ;
    	    }
	);

    }
);

and the test app throw an error showing an "-ERR record Command not found!\n" :

connected to media server 
connected to drachtio listening on tcp/192.168.0.1:5060,tcp/172.17.0.1:5060,tcp/127.0.0.1:5060,tcp/[::1]:5060,udp/192.168.0.1:5060,udp/172.17.0.1:5060,udp/127.0.0.1:5060,udp/[::1]:5060

received an authenticated registration request:  { type: 'register',
  expires: 900,
  contact: 
   [ { name: undefined,
       uri: 'sip:[email protected]:56169;ob',
       params: {} } ],
  aor: 'sip:[email protected]' }

conference created: { "name":"testconf","state":1,"memberId":-1,"confConn":{"confName":"testconf","createArgs":{"flags":["endconf","mute","vmute"]},"endpointUuid":"62f8121a-30dc-11e7-9217-ffa3ff9f17a5"},"maxMembers":-1,"locked":false}

error startRecording: 
{ "headers":
   [ { "name":"Content-Type","value":"api/response" },
     { "name":"Content-Length","value":31 }
   ],
   "hPtr":null,
   "body":"-ERR record Command not found!\n" }

/home/massimo/drachtio/rectest/rectest.js:66
			throw err ;
			^

sending invite request to myself says error: "cannot call to myself"

Hi,

i am working on the drachtio app and able to send and receive invites using the app...
now i want to send invite request to myself and facing trouble in this..... when i try to do it says error: "cannot call to myself"
below the block of code that is working fine for me..

//To send the invite

mrf.connect({ "address": "127.0.0.1", "port": 8021, "secret": "ClueCon" }).then(function (mediaserver) {
mediaserver.createEndpoint()
.then((endpoint) => {
ep = endpoint;
console.log(ep.local.sdp);
return srf.createUAC('sip:[email protected]', {
method: 'INVITE',
localSdp: ep.local.sdp,
callingNumber: [email protected]
});
})
.then((dlg) => {
const obj = { dlg, ep };
dialog.destroy().catch((err) => { });
ep.modify(dlg.remote.sdp);
console.log(obj);
});
});

//To receive the invite

srf.invite(async (req, res) => {
try {
const ms = await mrf.connect({ "address": "127.0.0.1", "port": 8021, "secret": "ClueCon" });
if (!ms) {
logger.info(rejecting incoming call from ${req.callingNumber}: freeswitch is down);
return res.send(480);
}
const { endpoint, dialog } = await ms.connectCaller(req, res);

    const sipTrunk = { "method": "INVITE", "gateway": "X.X.X.X" };
    const intent = { target: { number: '1003', type: 'phone' }, verb: 'dial', callerId: 'daveh' };
    let callTransfer = new CallTransfer(logger, dialog, sipTrunk, intent);
    if (callTransfer) {
        try {
            const dlgB = await callTransfer.execB2BUA();
            logger.info(`call transfer successfully completed to ${dlgB.local.uri}`);
            endpoint.execute("amd").then(function (evt, err) {
                evt.headers.forEach(function (evt) {
                    console.log(evt);
                    if (evt.name == "variable_amd_result") {
                        if (evt.value == "MACHINE") {

                            console.log(evt);
                            dialog.destroy().catch((err) => { });
                        }
                    }
                });
            });
        } catch (err) {
            if (err) logger.info(`Call transfer outdial failed with final status ${err}`);
            else logger.error({ err }, 'Call transfer outdial failed with unexpected error');
            dialog.destroy().catch((err) => { });
        }
    }
} catch (err) {
    logger.error(err, 'Error starting dialogflow');
    return;
}

});

kindly highlight the point where i am doing wrong or anything else i will have to do to send request to myself...

your help will be much appropriated,

regards:

Unhandled Promise rejection

Hello Dave,

In case srf.createUAC function is failed inside this.createEndpoint function, "You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection" error is raised and no callback is called to fsmrf app side.

I created PR #75

Thank you.

unable to find dialog for dialog id provided

Hey Dave,

Hope you had a great New Years!

I'm coming across a difficult scenario, sometimes we are attempting to end a call on Freeswitch when the call has already been destroyed. We have various catches looking for the destroy event emission, but there are scenarios where we're already off on a different async thread.

As such, we end up doing something like this:

if (endpoint.state != '3') endpoint.destroy()
dialog.destroy()

Checking the state of the endpoint helps us to not have any errors trying to kill an already dead endpoint, however I can't find a similar check for the dialog. If it's already been destroyed, we get the following:

unable to find dialog for dialog id provided

Is there a way we can check the dialog state similar to the endpoint state? Alternatively, can we safely ignore the dialog; Will drachtio clean it up later if/when Freeswitch advises it it's dead?

Thanks!

Andrew

endPoint.play does not return if call end by RemoteParty

we have a sample conneting to a local PhonerLite.

AsyncMain(process.mainModule == module, async () => {
    const srf = new Srf();
    srf.connect({host: '172.22.17.11', port: 9022, secret: 'cymru'});
    let hostport = await waitForEvent<string>(srf, 'connect');
    console.log('Connected ', hostport);
    const mrf = new Mrf(srf);
    let mediaserver = await mrf.connect({listenAddress: '172.22.17.9', address: '172.22.17.11', port: 8021, secret: 'ClueCon'});
    console.log('MediaServer Available');
    let endPoint = await mediaserver.createEndpoint();
    console.log('Endpoint created',endPoint.local.sdp);
    let dialog = await srf.createUAC('sip:[email protected]:5070', {
        localSdp: endPoint.local.sdp,
    }, {
        cbRequest: (err,req, res) => {
            console.log('CbReq...', err, );
        },
        cbProvisional: (res) => {
            console.log('ProvisionalResp...',res.status+' '+res.reason)
        }
    });
    await endPoint.dialog.modify(dialog.remote.sdp);
    dialog.on('destroy', (msg, reason) => {
        endPoint.destroy();
        console.log('got bye', reason);
    })
    console.log('Established');
    await waitFor(1000);
    await endPoint.play(['silence_stream://1000', 'voicemail/8000/vm-record_message.wav']);
    console.log('Done Playing')
    await endPoint.execute('send_dtmf', '1234@100');
    // console.log('done Play file');
    let answer = await endPoint.playCollect({file: 'silence_stream://200', min: 1, max: 4});
    console.log(answer);
    await waitFor(5*1000);
    console.log('Dest. Dialog');
    await dialog.destroy();
    console.log('Done');

});

The Playback works, but if the remoteparty (Phonerlite) hangs up during playback the Promise

await endPoint.play(['silence_stream://1000', 'voicemail/8000/vm-record_message.wav']);

never ends...

The destroy event from Dialog is fired

console.log('got bye', reason);

Strange Behaviour using "tone_stream://%(1850,4150,475,425);loops=-1" on playback

Hi, we have still a lot of fun (and Success)... :), but

we had made experiments using tone_stream with endPoint.play()

endPoint.play('tone_stream://%(100,15000,800);loops=-1');

It works, but with strange behavior if "loops=-1" (endless loop)

After you have send this play statement, any following call (even if you end your app and restart and reconnect to the DrachtIOServer) will have the tone playing.
You have to restart the DrachtIO/FreeSwitch construct to remove this behaviour.

Is the RTP EndPoint reused between different calls?

Inbound calls from classic sip endpoint (RTP) to WebRTC endpoint (SRTP) not working.

We started this conversation privately but just so everyone else can follow
and track our progress I will put it here too:

This module is currently in a state that allows us to make outbound calls from WebRTC client such as SIP.js to classic sip endpoint such as Bria but not the other way around (meaning we cannot receive any inbound calls from Bria endpoints to SIP.js endpoints.

The problem is with RTP (Bria) -> SRTP (SIP.js) invitation.

Looking for any ideas what is the blueprint to implement this.

Thanks!

reconnection no longer working

When we eliminated the dependency on my fork of node-esl we lost the reconnection logic that I had put in there; i.e if Freeswitch is restarted the app will not automatically reconnect. Need to restore this feature.

SDP Cut off on Invite from Drachtio->FreeSwitch

We've begin leveraging TURN servers for our WebRTC connections, and it seems to have pushed us over some kind of limit on the size of the SDP that can be sent from Drachtio -> Freeswitch. We noticed because we began getting some SIP 400s sent back to us from Freeswitch. When the SDP is cut off in a particular spot that breaks parsing, then a 400 results. Usually it seems to work anyway though because what is getting cut off doesn't seem to matter.

In the drachtio logs, I see the 2 invites (a) one from wp#send which contains the full SDP (I've cut off some of it to save space) and (b) the Msg sent: log which is what is actually sent to FS. Also notice the 2 Content-Lengths are different.

Do you have any idea what could be causing this?

Correct invite

2022-12-28T21:15:45.219Z drachtio:agent wp#send 0.0.0.0:9022 - 8671#03878403-7a04-4122-9eef-a10b5f60eff9|sip||
INVITE sip:[email protected]:5038 SIP/2.0
User-Agent: drachtio-fsmrf:d33ea6ce-4142-4585-9b61-a19c468267be
X-esl-outbound: 137.184.49.198:8103
Content-Length: 8452

v=0
o=- 85472555477210657 2 IN IP4 127.0.0.1
s=-
t=0 0
{.......... LOTS OF SDP ..... }
a=ssrc-group:FID 3683095972 3429814089
a=ssrc:3683095972 cname:OKoL/EIn4ZsuRc8D
a=ssrc:3683095972 msid:DkHMBAlVaOZNLJKkWbghoXzY3U61MFpRNPEW 3b3c6746-45c8-4554-86a0-88991e0f1109
a=ssrc:3429814089 cname:OKoL/EIn4ZsuRc8D
a=ssrc:3429814089 msid:DkHMBAlVaOZNLJKkWbghoXzY3U61MFpRNPEW 3b3c6746-45c8-4554-86a0-88991e0f1109

Cut off invite...notice the last line is cut

2022-12-28T21:15:45.221Z drachtio:agent <===9058#ed9ea344-3754-414f-99b7-e46b21533c9e|response|03878403-7a04-4122-9eef-a10b5f60eff9|OK|application|8866|tcp|104.131.19.169|5038|21:15:45.221075|54495c2e-c90d-464b-8b46-1e61cfe28138|Msg sent:|
INVITE sip:[email protected]:5038 SIP/2.0
Via: SIP/2.0/TCP 137.184.49.198;branch=z9hG4bKj6a582gKg6a2H
Max-Forwards: 70
From: <sip:137.184.49.198:5060>;tag=rcDX375t8y55j
To: <sip:[email protected]:5038>
Call-ID: a23eb86d-0197-123c-1585-0242ac110002
CSeq: 61577280 INVITE
Contact: <sip:137.184.49.198:5060>
User-Agent: drachtio-fsmrf:d33ea6ce-4142-4585-9b61-a19c468267be
Content-Type: application/sdp
Content-Length: 8384
X-esl-outbound: 137.184.49.198:8103

v=0
o=- 85472555477210657 2 IN IP4 127.0.0.1
s=-
t=0 0
{.......... LOTS OF SDP ..... }
a=ssrc-group:FID 3683095972 3429814089
a=ssrc:3683095972 cname:OKoL/EIn4ZsuRc8D
a=ssrc:3683095972 msid:DkHMBAlVaOZNLJKkWbghoXzY3U61MFpRNPEW 3b3c6746-45c8-4554-86a0-88991e0f1109
a=ssrc:3429814089 cname:OKoL/EIn4ZsuRc8D
a=ssrc:3429814089 msid:DkHMBAl      < ----- NOTICE THIS IS CUT OFF

Unable to create endpoint

I'm currently using drachtio-server to register to a Metaswitch switch using drachtio-srf, then I created a docker container in a AWS instance of drachtio-freeswitch-mrf. I'm able to both register to the Metaswitch server and connect to the drachtio-freeswitch-mrf using drachtio-fsmrf, however, when trying to create an endpoint on an incoming invite

srf.invite((req, res) => {
console.log("incoming voice call....")
mediaserver.connectCaller(req, res)
.then(({endpoint, dialog}) => {
console.log('successfully connected call to media server');
}).catch((err)=>{
console.log("could not create endpoint" + err)
});

I get a "connection timed out error"

drachtio:agent SIP/2.0 408 Request Timeout
drachtio:agent Via: SIP/2.0/UDP 172.31.44.73;rport;branch=z9hG4bKB1Z74Z77ee4FN
drachtio:agent From: sip:172.31.44.73:5060;tag=j0KUSa6rZZpeK
drachtio:agent To: sip:[email protected]:5080;tag=UaZHeXHNKK2jp
drachtio:agent Call-ID: 5da54e36-8e36-1238-7f88-12395f2083ba
drachtio:agent CSeq: 13012955 BYE
drachtio:agent Content-Length: 0

and on the fs_cli

2019-11-30 17:07:03.219600 [ERR] mod_event_socket.c:481 Socket Error: Connection timed out
2019-11-30 17:07:03.219600 [ERR] mod_event_socket.c:485 Socket Error!

What I'm trying achieve once I get the endpoint creation working is to play an mp3 file on outgoing/incoming calls using drachtio-fsmrf.

I'm using

"drachtio-fsmrf": "^1.5.7"
"drachtio-srf": "^4.4.22"
 FreeSWITCH Version 1.8.5+git~20190124T225359Z~31281a0bf1~64bit (git 31281a0 2019-> 
 01-24 22:53:59Z 64bit)
 drachtio-server -v 0.5.0-166-g782d405e5

Usage of Bridge and Unbridge

If you bridge too calls, is it needed to unbridge the call or just destory booth calls (or the other, with any of them finished)

Unable to connect Media Server ( Remote )

I have Drachtio Server hosted on a server, i can connect and run node apps from the server perfectly fine, but when i try to run it remortly it doesn't connect.

I tried editing ACL but didn't work out

{"level":30,"time":1593102971346,"pid":34771,"hostname":"Amanullahs-MacBook-Pro-2.local","msg":"connected to sip on tcp/95.217.176.58:5060,udp/95.217.176.58:5060"}

{"level":50,"time":1593102976326,"pid":34771,"hostname":"Amanullahs-MacBook-Pro-2.local","stack":"Error: Connection timeout}

"drachtio": { "host": "95.217.176.58", "port": 9022, "secret": "cymru" }, "freeswitch": { "address": "95.217.176.58", "port": 8021, "secret": "ClueCon" }

mrf.connect({ address: '95.217.176.58', port: 8021, secret: 'ClueCon' }) .then((mediaserver) => { console.log('successfully connected to mediaserver'); mediaserver.createEndpoint(function (ep) { console.log(ep); }); }) .catch((err) => { console.error(error connecting to mediaserver: ${err}); });

SRTP Errors when used after failed a B2BUA with RTPEngine

I'm trying to use FSMRF to take a voicemail after a failed (not answered) B2BUA call that uses RTPEngine as a media proxy. I switch passFailures to false on my B2BUA, then if it fails, I create an FSMRF session with connectCaller.

Freeswitch complains with a SRTP audio unprotect failed with code when I try to do this for SRTP calls. I'm guessing that it's because the SRTP was already negotiated between RTPEngine in my initial B2BUA call.

Any tips on how I can accomplish this use-case?

Pseudo code:

try {
  const response = await this.offer(Object.assign({'direction': [ 'private', 'public']}, this.rtpEngineOpts.offer));
  const {uas, uac} = await this.srf.createB2BUA(this.req, this.res, uri, {
    proxyResponseHeaders: ['all'],
    localSdpB: response.sdp,
    localSdpA: async(sdp, res) => {
      this.toTag = res.getParsedHeader('To').params.tag;
      const opts = Object.assign(this.rtpEngineOpts.answer, {sdp, 'to-tag': this.toTag});
      const response = await this.answer(opts);
      if ('ok' !== response.result) {
        this.logger.error(`rtpengine answer failed with ${JSON.stringify(response)}`);
        throw new Error('rtpengine failed: answer');
      }
      return response.sdp;
    },
    passFailure: true
  });
catch(e) {
  // caller not connected. take a voicemail
  const {endpoint, dialog} = await this.mediaserver.connectCaller(this.req, this.res, {});
  await endpoint.set('playback_terminators', '123456789#*');
  await endpoint.play(['silence_stream://1000', 'custom/8000/leave_a_message.wav', 'tone_stream://L=1;%(0500,0500,1000)']);
  recordingStarted = true;
  await endpoint.record('$${base_dir}/recordings/'+recordingString, {
    timeLimitSecs: 60
  });
  this.logger.info("Voicemail Time Limit Reached. Ending Call");
}

conference events

is there any way that you can emit all the conference event out? so we can do something like this:

conf.on(โ€œplay-file-memberโ€, (eve) => {
โ€ฆ.
});
conf.on(โ€œstart-talkingโ€, (eve) => {
โ€ฆ.
});

I also tried to do

ep.addCustomEventListener("conference::maintenance", (evt) => {
      console.log(`received conference event: ${evt}`);
});

But it doesโ€™t work, I guess because the join callback is removing all listeners:

https://github.com/davehorton/drachtio-fsmrf/blob/master/lib/endpoint.js#L562

endpoint.destroy() never returns if aws transcription is active

If you try to destroy an endpoint while an aws transcription is active, the destroy never succeeds and the call isn't torn down in FS.

Below is an example based on your aws transcription example.

async function doTts(dlg, ep) {
  try {
    await ep.play('silence_stream://1000');
    await ep.speak({
      ttsEngine: 'google_tts',
      voice: 'en-GB-Wavenet-A',
      text
    });
    var result = await ep.api('uuid_aws_transcribe', `${ep.uuid} start en-US interim`);  
    
    await delay(2000)    
    /*
    * without calling stop first, the below ep.destroy will never return
    * Comment it out to reproduce
    */
    console.log("stopping transcribe first")
    var result = await ep.api('uuid_aws_transcribe', `${ep.uuid} stop`);
    
    console.log("destroying main")
    await ep.destroy()
    
    // it won't ever get here if you don't stop the transcribe first
    console.log("destroyed main")
  }

  catch (err) {
    console.log(err, 'Error starting transcription');
  }
}

Here are the FS logs if you try to destroy an endpoint while transcription is still active:
failedDestroyLogs.txt

Here are the FS logs if you try to destroy an endpoint but stop transcription first (it works):
successDestroyLogs.txt

Optional headers is not set when transport is ws

Hello Dave,

I set optional headers to connectCaller function, these headers are not sent to freeswitch side when the SIP transport is wss.
But if transport is udp, headers are sent as expected.

I could see the optional headers is ignored inside connectCaller function.

      if (!requiresDtlsHandshake(req.body)) {
        const endpoint = await this.createEndpoint({
          ...opts,
          remoteSdp: opts.remoteSdp || req.body,
          codecs: opts.codecs
        });
        const dialog = await this.srf.createUAS(req, res, {
          localSdp: endpoint.local.sdp,
          headers: opts.headers
        });
        callback(null, {endpoint, dialog}) ;
      }
      else {
        // scenario 2: SRTP is being used and therefore creating an endpoint
        // involves completing a dtls handshake with the originator
        const pair = {};
        const uuid = generateUuid() ;
        const family = opts.family || 'ipv4' ;
        const uri = `sip:drachtio@${this.sip[family]['udp'].address}`;

        /* set state of a pending connection (ie waiting for esl outbound connection) */
        this.pendingConnections.set(uuid, {});

        /* send invite to freeswitch */
        **this.srf.createUAC(uri, {
          headers: {
            'User-Agent': `drachtio-fsmrf:${uuid}`,
            'X-esl-outbound': `${this.advertisedAddress}:${this.advertisedPort}`
          }**,
          localSdp: req.body
        }, {}, (err, dlg) => {

Could you consider fixing this?
Thanks.

msml support for drachtio

Hi Dave,

I'm looking for a solution to integrate drachtio-fsmrf with msml (media server markup language)
We're currently using SIP INFO with msml to create/destroy conference and play/collect DTMF digits.
Can you please share your suggestions here?

I found a GitHub project named "drachtio-msml" but its page returns 404
https://github.com/davehorton/drachtio-msml

Thanks,
Elliot

Override Private IP in X-esl-outbound

If you're running Drachtio SRF behind NAT there needs to be a way to override the X-esl-outbound header. Defining listenAddress as your Public IP in the config doesn't work, because a local machine behind NAT can't bind to the public address (only the local address).

Recording and playing audio doesn't work as expected

What I am trying to build is a virtual agent that allows audio input and output. I am using drachtio server combined with freeswitch as you can see here:

version: '2'

networks:
  drachtio-fsmrf:
    driver: bridge
    ipam:
      config:
        - subnet: 172.28.0.0/16

services:
  drachtio-uac:
    image: drachtio/drachtio-server:latest
    command: drachtio --contact "sip:*;transport=udp" --loglevel debug --sofia-loglevel 9
    container_name: drachtio-uac
    ports:
      - "9060:9022/tcp"
      - "5060:5060/tcp"
      - "5060:5060/udp"
    networks:
      drachtio-fsmrf:
        ipv4_address: 172.28.0.10

  freeswitch-uac:
    image: drachtio/drachtio-freeswitch-mrf:1.8.5-v0.2.1
    command: freeswitch --sip-port 5060 --rtp-range-start 20000 --rtp-range-end 20020
    container_name: freeswitch-uac
    volumes:
      - ./sounds:/usr/local/freeswitch/sounds
    ports:
      - "9070:8021/tcp"
      - "20000-20020:20000-20020/udp"
      - "20000-20020:20000-20020/tcp"
    networks:
      drachtio-fsmrf:
        ipv4_address: 172.28.0.11

And for recording audio I am using a similar example to the one founded in the examples/record folder.

const argv = require('minimist')(process.argv.slice(2));
const Srf = require('drachtio-srf');
const Mrf = require('drachtio-fsmrf')
var fs = require('fs')

const optsDrachtio = {
  host: argv['drachtio-address'] || '127.0.0.1',
  port: argv['drachtio-port'] || 9060,
  secret: argv['drachtio-secret'] || 'cymru'
} ;
const optsFreeswitch = {
  address: argv['freeswitch-address'] || '127.0.0.1',
  port: argv['freeswitch-port'] || 9070,
  secret: argv['freeswitch-secret'] || 'ClueCon'
};

const srf = new Srf() ;
srf.connect(optsDrachtio);

srf.on('connect', (err, hostport) => {
  console.log(`successfully connected to drachtio listening on ${hostport}`);
});

const mrf = new Mrf(srf) ;
mrf.connect(optsFreeswitch)
  .then((mediaserver) => {
    console.log('successfully connected to mediaserver');
    
        
    return srf.locals.ms = mediaserver;
  })
  .catch ((err) => {
    console.error(`error connecting to mediaserver: ${err}`);
  });


srf.register((req, res) => {
  console.log("Registering in the app");
  res.send(200);
})

srf.invite((req, res) => {
  const ms = req.app.locals.ms ;
  let ep;
  ms.connectCaller(req, res)
    .then(({endpoint, dialog}) => {
      console.log('successfully connected call');
      dialog.on('destroy', () => { endpoint.destroy(); });
      ep = endpoint ;
      return ep.set('RECORD_STEREO', true);
    })
    .then(() => {
      var file = fs.createWriteStream("file.mp3");
      
      return ep.record("file.mp3" ,{timeLimitSecs:20}) 
    })
    .then((evt) => {

      return ep.play(['silence_stream://1000', 'file.mp3']);
    })
    .then((res) => {
      console.log(`finished playing: ${JSON.stringify(res)}`);
      return ;
    })
    .catch ((err) => {
      console.log(`error connecting call to media server: ${err}`);
    });
}) ;

The only reason for register command is so that Zoiper could make a call to the service. The file is being created but nothing is stored. Also I already tried to use another examples and strategies, like mod_audio_fork module but without success. I know that this approach is not the best for what I want (literally a audio virtual agent), but it is a first step.

mediaserver.createEndpoint() does not return ...

We tried the Sample under test/script/callgenerator to created an EndPoint.

This is the code we use

async function waitForEvent<T>(waitfor: any, event:string): Promise<T> {
    return new Promise<T>((res,rej) => {
        waitfor.once(event, (err, val: T) => {
            if (err) return rej(err);
            res(val);
        })
    })
}

AsyncMain(process.mainModule == module, async () => {
    const srf = new Srf();
    srf.connect({host: '172.22.17.11', port: 9022, secret: 'cymru'});
    let hostport = await waitForEvent<string>(srf, 'connect');
    console.log('Connected ', hostport);
    const mrf = new Mrf(srf);
    let mediaserver = await mrf.connect({address: '172.22.17.11', port: 8021, secret: 'ClueCon'});
    console.log('MediaServer Available');
    let endPoint = await mediaserver.createEndpoint();
    console.log('Endpoint created',endPoint.local.sdp);
    console.log(mediaserver.sip);
});

The code never reaches 'EndPoint created' and timeouts after 10 seconds

Do you have any idea ? Maybe a Missconfiguration (SRF and Mrf are within the same docker machine 172.22.17.11)

This is the log

2018-11-23T09:14:15.373Z connect:dispatcher use * anonymous
2018-11-23T09:14:15.375Z drachtio:agent wp connecting (tcp) to 172.22.17.11:9022
2018-11-23T09:14:15.384Z drachtio:agent wp#on connect 172.22.17.11:9022
2018-11-23T09:14:15.385Z drachtio:socket _initServer: added socket: 9022:56266, count now: 1
2018-11-23T09:14:15.386Z drachtio:agent wp#send 172.22.17.11:9022 - 56#38ed6d79-a9a9-479f-bb59-1f864b2262bb|authenticate|cymru|
2018-11-23T09:14:15.387Z drachtio:agent <===151#34c157b8-2dac-4f71-99eb-9249e43b7da7|response|38ed6d79-a9a9-479f-bb59-1f864b2262bb|OK|udp/172.22.17.11:5060,udp/172.22.17.11:5060,udp/172.22.17.11:5060
2018-11-23T09:14:15.388Z drachtio:agent sucessfully authenticated, hostport is  udp/172.22.17.11:5060,udp/172.22.17.11:5060,udp/172.22.17.11:5060
Fri, 23 Nov 2018 09:14:15 GMT drachtio:fsmrf Mrf#connect - connecting to 172.22.17.11:8021
Fri, 23 Nov 2018 09:14:15 GMT drachtio:fsmrf initial connection made
Fri, 23 Nov 2018 09:14:15 GMT drachtio:fsmrf media server signaling addresses: {"ipv4":{"udp":{"address":"172.22.17.11:5038"},"dtls":{"address":"172.22.17.11:5039"}},"ipv6":{"udp":{},"dtls":{}}}
Fri, 23 Nov 2018 09:14:15 GMT drachtio:fsmrf Mrf#connect - media server is ready for action!
Fri, 23 Nov 2018 09:14:15 GMT drachtio:fsmrf MediaServer#createEndpoint: sending 3ppc INVITE to uri sip:[email protected]:5038 with id ededa669-83bb-422d-a613-cde6867c21e9
2018-11-23T09:14:15.434Z drachtio:socket _getDefaultSocket: there are 1 entries in mapServer
2018-11-23T09:14:15.434Z drachtio:socket _getDefaultSocket: returning socket 9022:56266
2018-11-23T09:14:15.434Z drachtio:socket _normalizeParams: using default socket provided in options._socket: 9022:56266
2018-11-23T09:14:15.434Z drachtio:agent options: {"uri":"sip:[email protected]:5038","method":"INVITE","headers":{"User-Agent":"drachtio-fsmrf:ededa669-83bb-422d-a613-cde6867c21e9","X-esl-outbound":"192.168.200.5:56268"}}
2018-11-23T09:14:15.434Z drachtio:socket _makeRequest: there are 1 entries in mapServer
2018-11-23T09:14:15.435Z drachtio:socket _makeRequest: calling wp.send using socket 9022:56266
2018-11-23T09:14:15.435Z drachtio:agent wp#send 172.22.17.11:9022 - 214#ed2493df-e100-43c2-b608-698e2e91efa5|sip||
INVITE sip:[email protected]:5038 SIP/2.0
User-Agent: drachtio-fsmrf:ededa669-83bb-422d-a613-cde6867c21e9
X-esl-outbound: 192.168.200.5:56268
Content-Length: 0


2018-11-23T09:14:15.440Z drachtio:agent <===632#2fb20942-cb39-4138-bdf7-27fa0afd03ad|response|ed2493df-e100-43c2-b608-698e2e91efa5|OK|application|445|udp|172.17.0.3|5060|09:14:15.472286|8d26ba7b-82dd-42d7-b66f-f061cc73940b|Msg sent:|
INVITE sip:[email protected]:5038 SIP/2.0
Via: SIP/2.0/UDP 172.22.17.11;rport;branch=z9hG4bKQpmF3r8yp2S9g
Max-Forwards: 70
From: <sip:172.22.17.11:5060>;tag=j0D9cK9pSj9Hp
To: <sip:[email protected]:5038>
Call-ID: fd912588-69a2-1237-ee8d-0242ac110003
CSeq: 131146163 INVITE
Contact: <sip:172.22.17.11:5060>
User-Agent: drachtio-fsmrf:ededa669-83bb-422d-a613-cde6867c21e9
Content-Length: 0
X-esl-outbound: 192.168.200.5:56268


2018-11-23T09:14:15.441Z drachtio-agent:request Request#set meta {"source":"application","address":"172.17.0.3","port":"5060","protocol":"udp","time":"09:14:15.472286","transactionId":"8d26ba7b-82dd-42d7-b66f-f061cc73940b"}
2018-11-23T09:14:15.488Z drachtio:agent <===1341#63ab8e52-f797-4404-a3aa-f96d4142e3f4|sip|network|1173|udp|172.22.17.11|5038|09:14:15.474721|8d26ba7b-82dd-42d7-b66f-f061cc73940b|b0b6db73-a701-4d6f-9ca9-f12b32ed0394|
SIP/2.0 200 OK
Via: SIP/2.0/UDP 172.22.17.11;rport=5060;branch=z9hG4bKQpmF3r8yp2S9g;received=172.17.0.3
From: <sip:172.22.17.11:5060>;tag=j0D9cK9pSj9Hp
To: <sip:[email protected]:5038>;tag=N9Kt6pjH2jtrQ
Call-ID: fd912588-69a2-1237-ee8d-0242ac110003
CSeq: 131146163 INVITE
Contact: <sip:[email protected]:5038;transport=udp>
User-Agent: drachtio MRF
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY
Supported: path, replaces
Allow-Events: talk, hold, conference, refer
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 537

v=0
o=FreeSWITCH 1542943505 1542943506 IN IP4 172.22.17.11
s=FreeSWITCH
c=IN IP4 172.22.17.11
t=0 0
m=audio 20950 RTP/AVP 0 102 103 8 101 104 106
a=rtpmap:0 PCMU/8000
a=rtpmap:102 opus/48000/2
a=fmtp:102 useinbandfec=0; cbr=1; maxaveragebitrate=30000; maxplaybackrate=48000; ptime=20; minptime=10; maxptime=40
a=rtpmap:103 SPEEX/32000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=rtpmap:104 telephone-event/48000
a=fmtp:104 0-16
a=rtpmap:106 telephone-event/32000
a=fmtp:106 0-16
a=ptime:20

2018-11-23T09:14:15.489Z drachtio:agent tokens: ["63ab8e52-f797-4404-a3aa-f96d4142e3f4","sip","network","1173","udp","172.22.17.11","5038","09:14:15.474721","8d26ba7b-82dd-42d7-b66f-f061cc73940b","b0b6db73-a701-4d6f-9ca9-f12b32ed0394",""]
2018-11-23T09:14:15.489Z drachtio:agent received sip response
2018-11-23T09:14:15.489Z drachtio:agent Agent#handle: got a response with status: 200
2018-11-23T09:14:15.490Z drachtio:agent sendMessage: ACK sip:[email protected]:5038 SIP/2.0
Content-Length: 0


2018-11-23T09:14:15.490Z drachtio:agent opts: {"body":"v=0\r\no=FreeSWITCH 1542943505 1542943506 IN IP4 0.0.0.0\r\ns=FreeSWITCH\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\nm=audio 20950 RTP/AVP 0 102 103 8 101 104 106\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:102 opus/48000/2\r\na=fmtp:102 useinbandfec=0; cbr=1; maxaveragebitrate=30000; maxplaybackrate=48000; ptime=20; minptime=10; maxptime=40\r\na=rtpmap:103 SPEEX/32000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-16\r\na=rtpmap:104 telephone-event/48000\r\na=fmtp:104 0-16\r\na=rtpmap:106 telephone-event/32000\r\na=fmtp:106 0-16\r\na=ptime:20\r\n","stackDialogId":"b0b6db73-a701-4d6f-9ca9-f12b32ed0394"}
2018-11-23T09:14:15.490Z drachtio:srf Srf#addDialog: adding dialog with id b0b6db73-a701-4d6f-9ca9-f12b32ed0394 type INVITE, dialog count is now 1 
2018-11-23T09:14:15.491Z drachtio:agent wp#send 172.22.17.11:9022 - 674#0b03a4bd-4571-431c-b58c-e4bdca93a55f|sip||b0b6db73-a701-4d6f-9ca9-f12b32ed0394
ACK sip:[email protected]:5038 SIP/2.0
Content-Length: 527

v=0
o=FreeSWITCH 1542943505 1542943506 IN IP4 0.0.0.0
s=FreeSWITCH
c=IN IP4 0.0.0.0
t=0 0
m=audio 20950 RTP/AVP 0 102 103 8 101 104 106
a=rtpmap:0 PCMU/8000
a=rtpmap:102 opus/48000/2
a=fmtp:102 useinbandfec=0; cbr=1; maxaveragebitrate=30000; maxplaybackrate=48000; ptime=20; minptime=10; maxptime=40
a=rtpmap:103 SPEEX/32000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=rtpmap:104 telephone-event/48000
a=fmtp:104 0-16
a=rtpmap:106 telephone-event/32000
a=fmtp:106 0-16
a=ptime:20

Fri, 23 Nov 2018 09:14:15 GMT drachtio:fsmrf MediaServer#createEndpoint - createUAC produced dialog for ededa669-83bb-422d-a613-cde6867c21e9
2018-11-23T09:14:15.493Z drachtio:agent <===1082#f63df174-60e9-4126-a21e-71e9adaaa140|response|0b03a4bd-4571-431c-b58c-e4bdca93a55f|OK|application|895|udp|172.17.0.3|5060|09:14:15.525217|63546e4a-c3be-452b-a55e-e60d0da94e57|Msg sent:|
ACK sip:[email protected]:5038;transport=udp SIP/2.0
Via: SIP/2.0/UDP 172.22.17.11;rport;branch=z9hG4bKrZD84KS2KBgvc
Max-Forwards: 70
From: <sip:172.22.17.11:5060>;tag=j0D9cK9pSj9Hp
To: <sip:[email protected]:5038>;tag=N9Kt6pjH2jtrQ
Call-ID: fd912588-69a2-1237-ee8d-0242ac110003
CSeq: 131146163 ACK
Content-Type: application/sdp
Content-Length: 527

v=0
o=FreeSWITCH 1542943505 1542943506 IN IP4 0.0.0.0
s=FreeSWITCH
c=IN IP4 0.0.0.0
t=0 0
m=audio 20950 RTP/AVP 0 102 103 8 101 104 106
a=rtpmap:0 PCMU/8000
a=rtpmap:102 opus/48000/2
a=fmtp:102 useinbandfec=0; cbr=1; maxaveragebitrate=30000; maxplaybackrate=48000; ptime=20; minptime=10; maxptime=40
a=rtpmap:103 SPEEX/32000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=rtpmap:104 telephone-event/48000
a=fmtp:104 0-16
a=rtpmap:106 telephone-event/32000
a=fmtp:106 0-16
a=ptime:20

2018-11-23T09:14:15.539Z drachtio:agent <===679#5d171724-5832-4eb7-a847-fe6161b5520b|sip|network|507|udp|172.22.17.11|1024|09:14:15.529615|a5b95efe-9600-4e51-9bd1-8315e3b19d7c|b0b6db73-a701-4d6f-9ca9-f12b32ed0394|
BYE sip:172.22.17.11:5060 SIP/2.0
Via: SIP/2.0/UDP 172.22.17.11:5038;rport=1024;branch=z9hG4bKN9Q7yjt72gpFe
Max-Forwards: 70
From: <sip:[email protected]:5038>;tag=N9Kt6pjH2jtrQ
To: <sip:172.22.17.11:5060>;tag=j0D9cK9pSj9Hp
Call-ID: fd912588-69a2-1237-ee8d-0242ac110003
CSeq: 131146163 BYE
User-Agent: drachtio MRF
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY
Supported: path, replaces
Reason: Q.850;cause=16;text="NORMAL_CLEARING"
Content-Length: 0


2018-11-23T09:14:15.539Z drachtio:agent tokens: ["5d171724-5832-4eb7-a847-fe6161b5520b","sip","network","507","udp","172.22.17.11","1024","09:14:15.529615","a5b95efe-9600-4e51-9bd1-8315e3b19d7c","b0b6db73-a701-4d6f-9ca9-f12b32ed0394",""]
2018-11-23T09:14:15.539Z drachtio:agent DrachtioAgent#_onMsg: meta: {"source":"network","address":"172.22.17.11","port":"1024","protocol":"udp","time":"09:14:15.529615","transactionId":"a5b95efe-9600-4e51-9bd1-8315e3b19d7c","dialogId":"b0b6db73-a701-4d6f-9ca9-f12b32ed0394"}
2018-11-23T09:14:15.539Z drachtio-agent:request Request#set meta {"source":"network","address":"172.22.17.11","port":"1024","protocol":"udp","time":"09:14:15.529615","transactionId":"a5b95efe-9600-4e51-9bd1-8315e3b19d7c","dialogId":"b0b6db73-a701-4d6f-9ca9-f12b32ed0394"}
2018-11-23T09:14:15.540Z drachtio-agent:response setting agent
2018-11-23T09:14:15.540Z connect:dispatcher handling request with method BYE
2018-11-23T09:14:15.540Z connect:dispatcher anonymous * : sip:172.22.17.11:5060
2018-11-23T09:14:15.540Z drachtio:srf examining BYE, dialog id: b0b6db73-a701-4d6f-9ca9-f12b32ed0394
2018-11-23T09:14:15.540Z drachtio:srf calling dialog handler
2018-11-23T09:14:15.540Z drachtio:srf Dialog handling message:  BYE
2018-11-23T09:14:15.541Z drachtio:srf Srf#removeDialog: removing dialog with id b0b6db73-a701-4d6f-9ca9-f12b32ed0394 dialog count is now 0
2018-11-23T09:14:15.541Z drachtio-agent:response Response#send: msg: {"headers":{"call-id":"fd912588-69a2-1237-ee8d-0242ac110003","cseq":"131146163 BYE","from":"<sip:[email protected]:5038>;tag=N9Kt6pjH2jtrQ","to":"<sip:172.22.17.11:5060>;tag=j0D9cK9pSj9Hp"},"status":200,"reason":"OK"}
2018-11-23T09:14:15.541Z drachtio:agent agent#sendResponse: {"headers":{"call-id":"fd912588-69a2-1237-ee8d-0242ac110003","cseq":"131146163 BYE","from":"<sip:[email protected]:5038>;tag=N9Kt6pjH2jtrQ","to":"<sip:172.22.17.11:5060>;tag=j0D9cK9pSj9Hp"},"status":200,"reason":"OK"}
2018-11-23T09:14:15.541Z drachtio:agent sendMessage: SIP/2.0 200 OK
Call-ID: fd912588-69a2-1237-ee8d-0242ac110003
cseq: 131146163 BYE
from: <sip:[email protected]:5038>;tag=N9Kt6pjH2jtrQ
to: <sip:172.22.17.11:5060>;tag=j0D9cK9pSj9Hp
Content-Length: 0


2018-11-23T09:14:15.541Z drachtio:agent opts: {"stackTxnId":"a5b95efe-9600-4e51-9bd1-8315e3b19d7c"}
2018-11-23T09:14:15.541Z drachtio:agent wp#send 172.22.17.11:9022 - 290#ff974562-91d1-4f0e-85b6-77318fd2c5c6|sip|a5b95efe-9600-4e51-9bd1-8315e3b19d7c|
SIP/2.0 200 OK
Call-ID: fd912588-69a2-1237-ee8d-0242ac110003
cseq: 131146163 BYE
from: <sip:[email protected]:5038>;tag=N9Kt6pjH2jtrQ
to: <sip:172.22.17.11:5060>;tag=j0D9cK9pSj9Hp
Content-Length: 0


2018-11-23T09:14:15.543Z drachtio:agent <===473#7a7b04ca-a9bb-4e83-be0b-70627aef73bd|response|ff974562-91d1-4f0e-85b6-77318fd2c5c6|OK|application|285||172.22.17.11|1024|09:14:15.575544|a5b95efe-9600-4e51-9bd1-8315e3b19d7c|||Msg sent:|
SIP/2.0 200 OK
Via: SIP/2.0/UDP 172.22.17.11:5038;rport=1024;branch=z9hG4bKN9Q7yjt72gpFe
From: <sip:[email protected]:5038>;tag=N9Kt6pjH2jtrQ
To: <sip:172.22.17.11:5060>;tag=j0D9cK9pSj9Hp
Call-ID: fd912588-69a2-1237-ee8d-0242ac110003
CSeq: 131146163 BYE
Content-Length: 0


Fri, 23 Nov 2018 09:14:25 GMT drachtio:fsmrf MediaServer#createEndpoint - connection timeout for ededa669-83bb-422d-a613-cde6867c21e9


Memory leak assistance

Hi Dave,

I've noticed a crash in my application the other day:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Some research shows that the application exceeded the default heap size of 1.5GB. I've since increased the heap size using the v8 --max_old_space_size option and added some monitoring of the heap size in Zabbix. I've noticed a sizeable increase of roughly 8MB per hour since doing so.

Can you point in the right direction for debugging memory allocation within an application using drachtio-srf and drachtio-fsmrf? I suspect the leak to come from the 1200 odd lines of average-at-best code I've written!

Thanks!

Limit calls

Dear,

I would like to know if it is possible to define a maximum number of calls. For example, when I have five calls established, the sixth one I reject.

I hope someone can help me

esl socket reconnecting repeatedly

Hi Dave,

When freeswitch is down, it seems drachtio-modesl try to connect to freeswitch repeatedly.
It seems to be a problem caused by the continuous emission of the net.socket end event.

Could you consider replacing socket end event to close event on the drachtio-modesl side?

Thanks.

this.socket.on('end', () => { self.emit('esl::end'); self.socket = null; if (this._inbound) { this._onConnectionGone(); } });

Freeswitch with mulitple sip profiles

HI,

I'm trying to use the same freeswitch instance to create enpoints on two different vlans, so I have two sip profiles, I have each of them a different context.

Does this framework provide a way to choose which profile to create the endpoint on?

callback variants of the api doesnt work

maybe it has been deprecated?

// works    
mediaserver.api(`conference asdf list count`).then(response => {
  console.log(response)
});


// used to work
mediaserver.api(`conference asdf list count`, result => {
  console.log(result) // undefined
});

endpoint modify method does not send reINVITE to far end

I ran into an issue where using the dialog modify method with a fsmrf endpoint does not send a reINVITE to the far end of the call. I only see the reINVITE being negotiated between drachtio and the drachtio-fsmrf freeswitch, but the reINVITE never gets sent out to the remote side. It appears to be because the endpoint only knows about the dialog between drachtio and the fsmrf, so it can only call the modify method on that stackDialogId when it invokes the modify method from srf.

Here is the code I ran that does not send a reINVITE to the remote end:

const modifyCall = (ep, dialog, holdBoolean, callback) => {
  if (holdBoolean) {
    ep.modify('hold', (err) => {
      if (err) { throw err; }
      return callback();
    });
  } else {
    ep.modify('unhold', (err) => {
      if (err) { throw err; }
      return callback();
    });
  }
}; // modifyCall

This code works fine because it directly calls the srf for the dialog with the remote end:

const modifyCall = (ep, dialog, holdBoolean, callback) => {
  if (holdBoolean) {
    dialog.modify('hold', (err) => {
      if (err) { throw err; }
      return callback();
    });
  } else {
    dialog.modify('unhold', (err) => {
      if (err) { throw err; }
      return callback();
    });
  }
}; // modifyCall

I am trying to figure if there is a simple way to get the remote dialog for the endpoint to use with the method so it can work as intended. I have not found a way yet.

Sample for Using with createUAC

Hi,
Sounds simply straightforward.

Is there a sample to use fsmrf in connection with createUAC.

In this Scenario we need a SDP for our first invite and later we need to process the incomming SDP...

using .say on endpoint works, but produces no audio

We had played a litte bit using .say on endpoint. (Play and PlayCollect works as expected!).
The api call returns successfull, but you cant hear anything.
This is the result from API

{
    "headers": [{
        "name": "Event-Name",
        "value": "CHANNEL_EXECUTE_COMPLETE"
    }, {
        "name": "Core-UUID",
        "value": "db0c3d70-f3d7-11e8-9f2c-0f677cc9bfd8"
    }, {
        "name": "FreeSWITCH-Hostname",
        "value": "default"
    }, {
        "name": "FreeSWITCH-Switchname",
        "value": "default"
    }, {
        "name": "FreeSWITCH-IPv4",
        "value": "172.22.17.11"
    }, {
        "name": "FreeSWITCH-IPv6",
        "value": "::1"
    }, {
        "name": "Event-Date-Local",
        "value": "2018-11-30 09:01:12"
    }, {
        "name": "Event-Date-GMT",
        "value": "Fri, 30 Nov 2018 09:01:12 GMT"
    }, {
        "name": "Event-Date-Timestamp",
        "value": "1543568472251893"
    }, {
        "name": "Event-Calling-File",
        "value": "switch_core_session.c"
    }, {
        "name": "Event-Calling-Function",
        "value": "switch_core_session_exec"
    }, {
        "name": "Event-Calling-Line-Number",
        "value": "2804"
    }, {
        "name": "Event-Sequence",
        "value": "11880"
    }, {
        "name": "Channel-State",
        "value": "CS_EXECUTE"
    }, {
        "name": "Channel-Call-State",
        "value": "ACTIVE"
    }, {
        "name": "Channel-State-Number",
        "value": "4"
    }, {
        "name": "Channel-Name",
        "value": "sofia/drachtio_mrf/[email protected]:5060"
    }, {
        "name": "Unique-ID",
        "value": "7da5d248-f47e-11e8-9ffc-0f677cc9bfd8"
    }, {
        "name": "Call-Direction",
        "value": "inbound"
    }, {
        "name": "Presence-Call-Direction",
        "value": "inbound"
    }, {
        "name": "Channel-HIT-Dialplan",
        "value": "true"
    }, {
        "name": "Channel-Call-UUID",
        "value": "7da5d248-f47e-11e8-9ffc-0f677cc9bfd8"
    }, {
        "name": "Answer-State",
        "value": "answered"
    }, {
        "name": "Channel-Read-Codec-Name",
        "value": "PCMU"
    }, {
        "name": "Channel-Read-Codec-Rate",
        "value": "8000"
    }, {
        "name": "Channel-Read-Codec-Bit-Rate",
        "value": "64000"
    }, {
        "name": "Channel-Write-Codec-Name",
        "value": "PCMU"
    }, {
        "name": "Channel-Write-Codec-Rate",
        "value": "8000"
    }, {
        "name": "Channel-Write-Codec-Bit-Rate",
        "value": "64000"
    }, {
        "name": "Caller-Direction",
        "value": "inbound"
    }, {
        "name": "Caller-Logical-Direction",
        "value": "inbound"
    }, {
        "name": "Caller-Dialplan",
        "value": "XML"
    }, {
        "name": "Caller-Caller-ID-Name",
        "value": "unknown"
    }, {
        "name": "Caller-Orig-Caller-ID-Name",
        "value": "unknown"
    }, {
        "name": "Caller-Network-Addr",
        "value": "172.22.17.11"
    }, {
        "name": "Caller-Destination-Number",
        "value": "drachtio"
    }, {
        "name": "Caller-Unique-ID",
        "value": "7da5d248-f47e-11e8-9ffc-0f677cc9bfd8"
    }, {
        "name": "Caller-Source",
        "value": "mod_sofia"
    }, {
        "name": "Caller-Context",
        "value": "mrf"
    }, {
        "name": "Caller-Channel-Name",
        "value": "sofia/drachtio_mrf/[email protected]:5060"
    }, {
        "name": "Caller-Profile-Index",
        "value": "1"
    }, {
        "name": "Caller-Profile-Created-Time",
        "value": "1543568460951832"
    }, {
        "name": "Caller-Channel-Created-Time",
        "value": "1543568460951832"
    }, {
        "name": "Caller-Channel-Answered-Time",
        "value": "1543568461012561"
    }, {
        "name": "Caller-Channel-Progress-Time",
        "value": "0"
    }, {
        "name": "Caller-Channel-Progress-Media-Time",
        "value": "0"
    }, {
        "name": "Caller-Channel-Hangup-Time",
        "value": "0"
    }, {
        "name": "Caller-Channel-Transfer-Time",
        "value": "0"
    }, {
        "name": "Caller-Channel-Resurrect-Time",
        "value": "0"
    }, {
        "name": "Caller-Channel-Bridged-Time",
        "value": "0"
    }, {
        "name": "Caller-Channel-Last-Hold",
        "value": "0"
    }, {
        "name": "Caller-Channel-Hold-Accum",
        "value": "0"
    }, {
        "name": "Caller-Screen-Bit",
        "value": "true"
    }, {
        "name": "Caller-Privacy-Hide-Name",
        "value": "false"
    }, {
        "name": "Caller-Privacy-Hide-Number",
        "value": "false"
    }, {
        "name": "variable_direction",
        "value": "inbound"
    }, {
        "name": "variable_uuid",
        "value": "7da5d248-f47e-11e8-9ffc-0f677cc9bfd8"
    }, {
        "name": "variable_session_id",
        "value": "60"
    }, {
        "name": "variable_sip_from_user",
        "value": "nobody"
    }, {
        "name": "variable_sip_from_port",
        "value": "5060"
    }, {
        "name": "variable_sip_from_uri",
        "value": "[email protected]:5060"
    }, {
        "name": "variable_sip_from_host",
        "value": "172.22.17.11"
    }, {
        "name": "variable_video_media_flow",
        "value": "sendrecv"
    }, {
        "name": "variable_channel_name",
        "value": "sofia/drachtio_mrf/[email protected]:5060"
    }, {
        "name": "variable_sip_local_network_addr",
        "value": "172.22.17.11"
    }, {
        "name": "variable_sip_network_ip",
        "value": "172.22.17.11"
    }, {
        "name": "variable_sip_network_port",
        "value": "5060"
    }, {
        "name": "variable_sip_invite_stamp",
        "value": "1543568460951832"
    }, {
        "name": "variable_sip_received_ip",
        "value": "172.22.17.11"
    }, {
        "name": "variable_sip_received_port",
        "value": "5060"
    }, {
        "name": "variable_sip_via_protocol",
        "value": "udp"
    }, {
        "name": "variable_sofia_profile_name",
        "value": "drachtio_mrf"
    }, {
        "name": "variable_recovery_profile_name",
        "value": "drachtio_mrf"
    }, {
        "name": "variable_sip_req_user",
        "value": "drachtio"
    }, {
        "name": "variable_sip_req_port",
        "value": "5038"
    }, {
        "name": "variable_sip_req_uri",
        "value": "[email protected]:5038"
    }, {
        "name": "variable_sip_req_host",
        "value": "172.22.17.11"
    }, {
        "name": "variable_sip_to_user",
        "value": "drachtio"
    }, {
        "name": "variable_sip_to_port",
        "value": "5038"
    }, {
        "name": "variable_sip_to_uri",
        "value": "[email protected]:5038"
    }, {
        "name": "variable_sip_to_host",
        "value": "172.22.17.11"
    }, {
        "name": "variable_sip_contact_user",
        "value": "nobody"
    }, {
        "name": "variable_sip_contact_port",
        "value": "5060"
    }, {
        "name": "variable_sip_contact_uri",
        "value": "[email protected]:5060"
    }, {
        "name": "variable_sip_contact_host",
        "value": "172.22.17.11"
    }, {
        "name": "variable_sip_user_agent",
        "value": "drachtio-fsmrf:72067311-eb3e-43a2-8fab-37c76617f3ce"
    }, {
        "name": "variable_sip_via_host",
        "value": "172.22.17.11"
    }, {
        "name": "variable_sip_via_rport",
        "value": "5060"
    }, {
        "name": "variable_max_forwards",
        "value": "70"
    }, {
        "name": "variable_sip_h_X-esl-outbound",
        "value": "172.22.17.9:62592"
    }, {
        "name": "variable_sip_reinvite_sdp",
        "value": "v=0\\r\\no=FreeSWITCH 1543547592 1543547593 IN IP4 0.0.0.0\\r\\ns=FreeSWITCH\\r\\nc=IN IP4 0.0.0.0\\r\\nt=0 0\\r\\nm=audio 20868 RTP/AVP 0 102 103 8 101 104 106\\r\\na=rtpmap:0 PCMU/8000\\r\\na=rtpmap:102 opus/48000/2\\r\\na=fmtp:102 useinbandfec=0; cbr=1; maxaveragebitrate=30000; maxplaybackrate=48000; ptime=20; minptime=10; maxptime=40\\r\\na=rtpmap:103 SPEEX/32000\\r\\na=rtpmap:8 PCMA/8000\\r\\na=rtpmap:101 telephone-event/8000\\r\\na=fmtp:101 0-16\\r\\na=rtpmap:104 telephone-event/48000\\r\\na=fmtp:104 0-16\\r\\na=rtpmap:106 telephone-event/32000\\r\\na=fmtp:106 0-16\\r\\na=ptime:20\\r\\n"
    }, {
        "name": "variable_rtp_use_codec_name",
        "value": "PCMU"
    }, {
        "name": "variable_rtp_use_codec_rate",
        "value": "8000"
    }, {
        "name": "variable_rtp_use_codec_ptime",
        "value": "20"
    }, {
        "name": "variable_rtp_use_codec_channels",
        "value": "1"
    }, {
        "name": "variable_rtp_last_audio_codec_string",
        "value": "PCMU@8000h@20i@1c"
    }, {
        "name": "variable_read_codec",
        "value": "PCMU"
    }, {
        "name": "variable_original_read_codec",
        "value": "PCMU"
    }, {
        "name": "variable_read_rate",
        "value": "8000"
    }, {
        "name": "variable_original_read_rate",
        "value": "8000"
    }, {
        "name": "variable_write_codec",
        "value": "PCMU"
    }, {
        "name": "variable_write_rate",
        "value": "8000"
    }, {
        "name": "variable_rtp_use_timer_name",
        "value": "soft"
    }, {
        "name": "variable_rtp_use_pt",
        "value": "0"
    }, {
        "name": "variable_rtp_use_ssrc",
        "value": "2416394554"
    }, {
        "name": "variable_endpoint_disposition",
        "value": "ANSWER"
    }, {
        "name": "variable_DP_MATCH",
        "value": ["drachtio-fsmrf:72067311-eb3e-43a2-8fab-37c76617f3ce", "72067311-eb3e-43a2-8fab-37c76617f3ce"]
    }, {
        "name": "variable_call_uuid",
        "value": "7da5d248-f47e-11e8-9ffc-0f677cc9bfd8"
    }, {
        "name": "variable_socket_host",
        "value": "172.22.17.9"
    }, {
        "name": "variable_rtp_audio_in_raw_bytes",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_in_media_bytes",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_in_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_in_media_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_in_skip_packet_count",
        "value": "2"
    }, {
        "name": "variable_rtp_audio_in_jitter_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_in_dtmf_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_in_cng_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_in_flush_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_in_largest_jb_size",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_in_jitter_min_variance",
        "value": "0.00"
    }, {
        "name": "variable_rtp_audio_in_jitter_max_variance",
        "value": "0.00"
    }, {
        "name": "variable_rtp_audio_in_jitter_loss_rate",
        "value": "0.00"
    }, {
        "name": "variable_rtp_audio_in_jitter_burst_rate",
        "value": "0.00"
    }, {
        "name": "variable_rtp_audio_in_mean_interval",
        "value": "0.00"
    }, {
        "name": "variable_rtp_audio_in_flaw_total",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_in_quality_percentage",
        "value": "100.00"
    }, {
        "name": "variable_rtp_audio_in_mos",
        "value": "4.50"
    }, {
        "name": "variable_rtp_audio_out_raw_bytes",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_out_media_bytes",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_out_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_out_media_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_out_skip_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_out_dtmf_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_out_cng_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_rtcp_packet_count",
        "value": "0"
    }, {
        "name": "variable_rtp_audio_rtcp_octet_count",
        "value": "0"
    }, {
        "name": "variable_switch_r_sdp",
        "value": "v=0\\r\\no=FreeSWITCH 1543543525 1543543526 IN IP4 92.197.178.227\\r\\ns=FreeSWITCH\\r\\nc=IN IP4 92.197.178.227\\r\\nt=0 0\\r\\nm=audio 24952 RTP/AVP 0 101\\r\\na=rtpmap:0 PCMU/8000\\r\\na=rtpmap:101 telephone-event/8000\\r\\na=fmtp:101 0-16\\r\\na=ptime:20\\r\\n"
    }, {
        "name": "variable_rtp_use_codec_string",
        "value": "PCMU,OPUS,G722,speex@32000h@20i,PCMA"
    }, {
        "name": "variable_audio_media_flow",
        "value": "sendrecv"
    }, {
        "name": "variable_rtp_audio_recv_pt",
        "value": "0"
    }, {
        "name": "variable_dtmf_type",
        "value": "rfc2833"
    }, {
        "name": "variable_rtp_2833_send_payload",
        "value": "101"
    }, {
        "name": "variable_rtp_2833_recv_payload",
        "value": "101"
    }, {
        "name": "variable_rtp_local_sdp_str",
        "value": "v=0\\r\\no=FreeSWITCH 1543547592 1543547594 IN IP4 172.22.17.11\\r\\ns=FreeSWITCH\\r\\nc=IN IP4 172.22.17.11\\r\\nt=0 0\\r\\nm=audio 20868 RTP/AVP 0 101\\r\\na=rtpmap:0 PCMU/8000\\r\\na=rtpmap:101 telephone-event/8000\\r\\na=fmtp:101 0-16\\r\\na=ptime:20\\r\\na=sendrecv\\r\\n"
    }, {
        "name": "variable_remote_media_ip",
        "value": "92.197.178.227"
    }, {
        "name": "variable_remote_media_port",
        "value": "24952"
    }, {
        "name": "variable_local_media_ip",
        "value": "172.22.17.11"
    }, {
        "name": "variable_local_media_port",
        "value": "20868"
    }, {
        "name": "variable_advertised_media_ip",
        "value": "172.22.17.11"
    }, {
        "name": "variable_sip_to_tag",
        "value": "j27cUc73HBrgg"
    }, {
        "name": "variable_sip_from_tag",
        "value": "Q80BFmBDZgBBe"
    }, {
        "name": "variable_sip_cseq",
        "value": "131448174"
    }, {
        "name": "variable_sip_call_id",
        "value": "5503fce2-6f21-1237-34a2-3ac0b2717a22"
    }, {
        "name": "variable_sip_full_via",
        "value": "SIP/2.0/UDP 172.22.17.11;rport=5060;branch=z9hG4bKavev90BN0U92K"
    }, {
        "name": "variable_sip_full_from",
        "value": "<sip:172.22.17.11:5060>;tag=Q80BFmBDZgBBe"
    }, {
        "name": "variable_sip_full_to",
        "value": "<sip:[email protected]:5038>;tag=j27cUc73HBrgg"
    }, {
        "name": "variable_read_result",
        "value": "success"
    }, {
        "name": "variable_myDigitBuffer",
        "value": "1234"
    }, {
        "name": "variable_playback_last_offset_pos",
        "value": "16000"
    }, {
        "name": "variable_playback_seconds",
        "value": "2"
    }, {
        "name": "variable_playback_ms",
        "value": "2000"
    }, {
        "name": "variable_playback_samples",
        "value": "16000"
    }, {
        "name": "variable_current_loop",
        "value": "1"
    }, {
        "name": "variable_total_loops",
        "value": "1"
    }, {
        "name": "variable_current_application_data",
        "value": "en MESSAGES pronounced Hello Folks"
    }, {
        "name": "variable_current_application",
        "value": "say"
    }, {
        "name": "Application",
        "value": "say"
    }, {
        "name": "Application-Data",
        "value": "en MESSAGES pronounced Hello Folks"
    }, {
        "name": "Application-Response",
        "value": "_none_"
    }, {
        "name": "Application-UUID",
        "value": "5b319710-fcb0-4dc0-92ef-d47faf3038ca"
    }],
    "hPtr": null,
    "type": "CHANNEL_EXECUTE_COMPLETE",
    "body": ""
}

feature request: enhancements to Endpoint#play method

Currently, the Endpoint#play method takes either a single file (as a string) or an array of files (as an array). I would like to offer another possibility:

  • the method takes an object, which contains a single file to play and a seek offset at which to start playing it (ie can play from somewhere in the middle of the file). See here for details on how to play a file on freeswitch from a given offset.

So for example, this would be possible:

ep.play({file: 'http://example.com/recording.wav, seekOffset: 7000});

If an object is passed it can have the following properties:

The method should then play the fill starting from the given offset.

This option is only available when playing a single file, not an array of files.

Furthermore, when the play is done we currently call the callback and pass back playbackSeconds and playbackMilliseconds to tell the caller how much of the call was played. This payload should be enhanced to include:

Problems overwriting User-Agent header

Hi Dave,

When i call the connectCaller with my own headers, "User-Agent" header is not overwritten.

const {endpoint, dialog} = await mediaserver.connectCaller(req, res, {
headers: {
'User-Agent': 'spointer',
'X-version': 'v0.1.0'
}
});

The actual INVITE 200 OK header is as follows:

SIP/2.0 200 OK
Via: SIP/2.0/UDP x.x.x.x:5060;branch=z9hG4bK1d3e92ab45f8661d8-1b38d-0_111501;rport=5060
Via: SIP/2.0/UDP x.x.x.x:5060;branch=z9hG4bK1d3e92ab45f8661d8-1b38d-0
Record-Route: sip:x.x.x.x;lr
From: sip:[email protected];tag=6b81a7f403ae430c783f9927021fa35c
To: sip:[email protected];tag=3DDQ39K2v389j
Call-ID: AAkyo3__AdgAABez0-lBRw--c4407075
CSeq: 111501 INVITE
Contact: sip:172.26.0.2:3459
User-Agent: drachtio-fsmrf:98242b28-424f-496c-99e6-d53d09d8e57e
Content-Type: application/sdp
Content-Length: 228
X-version: v0.1.0
X-esl-outbound: 192.168.10.200:53599

v=0
o=spointer 1602619950 1602619951 IN IP4 172.26.0.4
s=spointer
c=IN IP4 172.26.0.4
t=0 0
m=audio 22444 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

I see createUAS is called inside the connectCaller function and it sets custom headers as you explained in your API reference like this.

srf.invite((req, res) => {
let mySdp; // populated somehow with SDP we want to answer in 200 OK
srf.createUas(req, res, {
localSdp: mySdp,
headers: {
'User-Agent': 'drachtio/iechyd-da',
'X-Linked-UUID': '1e2587c'
}
}, (err, uas) => {
if (err) return console.log(Error creating dialog: ${err});
console.log(dialog established, local tag is ${uas.sip.localTag});

  uas.on('destroy', () => console.log('caller hung up'));
});

});

Any suggestions are appreciated.

Error: write EPIPE

Hi @davehorton

We are getting the following error at random intervals with the following stacktrace:

2023-07-12T15:18:54: received INVITE with unknown uuid: 7da7499b-7fd0-4b62-840d-f2baa91e9480 2023-07-12T15:18:54: Error: write EPIPE 2023-07-12T15:18:54: at afterWriteDispatched (internal/stream_base_commons.js:156:25) 2023-07-12T15:18:54: at writeGeneric (internal/stream_base_commons.js:147:3) 2023-07-12T15:18:54: at Socket._writeGeneric (net.js:798:11) 2023-07-12T15:18:54: at Socket._write (net.js:810:8) 2023-07-12T15:18:54: at writeOrBuffer (internal/streams/writable.js:358:12) 2023-07-12T15:18:54: at Socket.Writable.write (internal/streams/writable.js:303:10) 2023-07-12T15:18:54: at module.exports.Connection.send (/home/sbt/superbot/node_modules/drachtio-modesl/lib/esl/Connection.js:204:21) 2023-07-12T15:18:54: at module.exports.Connection.sendRecv (/home/sbt/superbot/node_modules/drachtio-modesl/lib/esl/Connection.js:232:10) 2023-07-12T15:18:54: at module.exports.Connection.events (/home/sbt/superbot/node_modules/drachtio-modesl/lib/esl/Connection.js:417:10) 2023-07-12T15:18:54: at module.exports.Connection.subscribe (/home/sbt/superbot/node_modules/drachtio-modesl/lib/esl/Connection.js:560:10) 2023-07-12T15:18:54: at module.exports.<anonymous> (/home/sbt/superbot/node_modules/drachtio-modesl/lib/esl/Connection.js:106:18) 2023-07-12T15:18:54: at module.exports.listener (/home/sbt/superbot/node_modules/eventemitter2/lib/eventemitter2.js:288:17) 2023-07-12T15:18:54: at module.exports.EventEmitter.emit (/home/sbt/superbot/node_modules/eventemitter2/lib/eventemitter2.js:382:22) 2023-07-12T15:18:54: at module.exports.Connection._onEvent (/home/sbt/superbot/node_modules/drachtio-modesl/lib/esl/Connection.js:797:22) 2023-07-12T15:18:54: at module.exports.EventEmitter.emit (/home/sbt/superbot/node_modules/eventemitter2/lib/eventemitter2.js:388:22) 2023-07-12T15:18:54: at module.exports.Parser._parseEvent (/home/sbt/superbot/node_modules/drachtio-modesl/lib/esl/Parser.js:208:10) { 2023-07-12T15:18:54: errno: -32, 2023-07-12T15:18:54: code: 'EPIPE', 2023-07-12T15:18:54: syscall: 'write' 2023-07-12T15:18:54: }

Video call between an intercom device (SIP) and a web client (WebRTC)

Hi Dave,

I know this is it a query and not an issue but I can't answer for any other site.

I have a drachtio-fsmrf node process running and connected correctly with the drachtio-server and freeswitch media server.

I perform a call from a video door phone and drachtio receive it but I can't do anything else more. How can I set up a video call from the web or at least play the video call? I trying to integrate SIP.js but I can't do it right or it does not work.

The basic flow for the PoC would be as follows:

  • SIP device (video door entry) initiates call to the server
  • Server receive the call
  • The client can contest the videocall using a web page.

The drachtio-fsmrf log when receive the call:

connected to media server 
connected to drachtio listening on 174.31.10.81
Invitation received!

and the drachtio-server log when receive the call:

00001b4b|2017-Jun-27 07:48:59.048253| tport.c:2749 tport_wakeup_pri() tport_wakeup_pri(0x2460d00): events IN
00001b4c|2017-Jun-27 07:48:59.048351| tport.c:2864 tport_recv_event() tport_recv_event(0x2460d00)
00001b4d|2017-Jun-27 07:48:59.048383| tport.c:3205 tport_recv_iovec() tport_recv_iovec(0x2460d00) msg 0x24c4b90 from (udp/174.31.10.81:5060) has 1059 bytes, veclen = 1
00001b4e|2017-Jun-27 07:48:59.048505| recv 1059 bytes from udp/[83.56.45.209]:5060 at 07:48:59.048403:
INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.9.54:5060;rport;branch=z9hG4bK1186645242
From: "GetFace IP" <sip:[email protected]>;tag=1705390330
To: <sip:[email protected]>
Call-ID: 1001992504
CSeq: 20 INVITE
Contact: <sip:[email protected]:5060>
Content-Type: application/sdp
Allow: REGISTER, INVITE, ACK, CANCEL, OPTIONS, BYE, INFO, NOTIFY
Max-Forwards: 70
User-Agent: GetFace IP 2.18.0.27.5
Content-Length:   597

v=0
o=- 1024885257 1205277739 IN IP4 192.168.9.54
s=HIP 2.18.0.27.5
c=IN IP4 192.168.9.54
t=0 0
m=audio 5000 RTP/AVP 9 0 8 101
c=IN IP4 192.168.9.54
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
m=video 5002 RTP/AVP 123 124 98 34
c=IN IP4 192.168.9.54
a=sendonly
a=rtpmap:123 H264/90000
a=fmtp:123 profile-level-id=42801E; packetization-mode=1
a=rtpmap:124 H264/90000
a=fmtp:124 profile-level-id=42801E; packetization-mode=0
a=rtpmap:98 H263-1998/90000
a=fmtp:98 QCIF=1; CIF=1
a=rtpmap:34 H263/90000
a=fmtp:34 QCIF=1; CIF=1 
00001b4f|2017-Jun-27 07:48:59.048547| tport.c:3023 tport_deliver() tport_deliver(0x2460d00): msg 0x24c4b90 (1059 bytes) from udp/83.56.45.209:5060 next=(nil)
00001b50|2017-Jun-27 07:48:59.048564| nta.c:2880 agent_recv_request() nta: received INVITE sip:[email protected] SIP/2.0 (CSeq 20)
00001b51|2017-Jun-27 07:48:59.048579| nta.c:3174 agent_check_request_via() nta: Via check: received=83.56.45.209
00001b52|2017-Jun-27 07:48:59.048597| nta.c:3094 agent_recv_request() nta: INVITE (20) to message callback
00001b53|2017-Jun-27 07:48:59.048639| tport.c:3257 tport_tsend() tport_tsend(0x2460d00) tpn = UDP/83.56.45.209:5060
00001b54|2017-Jun-27 07:48:59.048660| tport.c:4046 tport_resolve() tport_resolve addrinfo = 83.56.45.209:5060
00001b55|2017-Jun-27 07:48:59.048673| tport.c:4680 tport_by_addrinfo() tport_by_addrinfo(0x2460d00): not found by name UDP/83.56.45.209:5060
00001b56|2017-Jun-27 07:48:59.048716| tport.c:3492 tport_send_msg() tport_vsend returned 269
00001b57|2017-Jun-27 07:48:59.048751| send 269 bytes to udp/[83.56.45.209]:5060 at 07:48:59.048689:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.9.54:5060;rport=5060;branch=z9hG4bK1186645242;received=83.56.45.209
From: "GetFace IP" <sip:[email protected]>;tag=1705390330
To: <sip:[email protected]>
Call-ID: 1001992504
CSeq: 20 INVITE
Content-Length: 0
 
00001b58|2017-Jun-27 07:48:59.052591| nta.c:4417 nta_leg_tcreate() nta_leg_tcreate(0x24c7400)
00001b59|2017-Jun-27 07:48:59.052695| nta.c:2665 nta_tpn_by_url() nta: selecting scheme sip
00001b5a|2017-Jun-27 07:48:59.052784| tport.c:3257 tport_tsend() tport_tsend(0x2460d00) tpn = */174.31.10.81:5080
00001b5b|2017-Jun-27 07:48:59.052852| tport.c:4046 tport_resolve() tport_resolve addrinfo = 174.31.10.81:5080
00001b5c|2017-Jun-27 07:48:59.052907| tport.c:4680 tport_by_addrinfo() tport_by_addrinfo(0x2460d00): not found by name */174.31.10.81:5080
00001b5d|2017-Jun-27 07:48:59.056386| tport.c:3492 tport_send_msg() tport_vsend returned 1057
00001b5e|2017-Jun-27 07:48:59.056513| send 1057 bytes to udp/[174.31.10.81]:5080 at 07:48:59.052972:
INVITE sip:[email protected]:5080 SIP/2.0
Via: SIP/2.0/UDP 174.31.10.81;branch=z9hG4bKQ929cy06H1g0H
Max-Forwards: 70
From: <sip:174.31.10.81>;tag=tgUpHBrDgNZ1r
To: <sip:[email protected]:5080>
Call-ID: eb9e2d9b-d5af-1235-d09c-0ac4d0dfda04
CSeq: 108938805 INVITE
Contact: <sip:174.31.10.81>
User-Agent: drachtio-fsmrf:9bf755ae-7f17-4343-bfbb-4c75cd7fb430
Content-Type: application/sdp
Content-Length: 597
X-esl-outbound: 174.31.10.81:8085

v=0
o=- 1024885257 1205277739 IN IP4 192.168.9.54
s=HIP 2.18.0.27.5
c=IN IP4 192.168.9.54
t=0 0
m=audio 5000 RTP/AVP 9 0 8 101
c=IN IP4 192.168.9.54
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
m=video 5002 RTP/AVP 123 124 98 34
c=IN IP4 192.168.9.54
a=sendonly
a=rtpmap:123 H264/90000
a=fmtp:123 profile-level-id=42801E; packetization-mode=1
a=rtpmap:124 H264/90000
a=fmtp:124 profile-level-id=42801E; packetization-mode=0
a=rtpmap:98 H263-1998/90000
a=fmtp:98 QCIF=1; CIF=1
a=rtpmap:34 H263/90000
a=fmtp:34 QCIF=1; CIF=1 
00001b5f|2017-Jun-27 07:48:59.056776| nta.c:8304 outgoing_send() nta: sent INVITE (108938805) to */174.31.10.81:5080
00001b60|2017-Jun-27 07:48:59.056836| tport.c:4160 tport_pend() tport_pend(0x2460d00): pending 0x24c58c0 for udp/174.31.10.81:5060 (already 0)
00001b61|2017-Jun-27 07:48:59.056895| nta.c:1348 set_timeout() nta: timer shortened to 1000 ms
00001b62|2017-Jun-27 07:48:59.058889| tport.c:2749 tport_wakeup_pri() tport_wakeup_pri(0x2460d00): events IN
00001b63|2017-Jun-27 07:48:59.058971| tport.c:2864 tport_recv_event() tport_recv_event(0x2460d00)
00001b64|2017-Jun-27 07:48:59.059059| tport.c:3205 tport_recv_iovec() tport_recv_iovec(0x2460d00) msg 0x24c8540 from (udp/174.31.10.81:5060) has 279 bytes, veclen = 1
00001b65|2017-Jun-27 07:48:59.059161| recv 279 bytes from udp/[174.31.10.81]:5080 at 07:48:59.059114:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 174.31.10.81;branch=z9hG4bKQ929cy06H1g0H
From: <sip:174.31.10.81>;tag=tgUpHBrDgNZ1r
To: <sip:[email protected]:5080>
Call-ID: eb9e2d9b-d5af-1235-d09c-0ac4d0dfda04
CSeq: 108938805 INVITE
User-Agent: drachtio MRF
Content-Length: 0
 
00001b66|2017-Jun-27 07:48:59.059228| tport.c:3023 tport_deliver() tport_deliver(0x2460d00): msg 0x24c8540 (279 bytes) from udp/174.31.10.81:5060 next=(nil)
00001b67|2017-Jun-27 07:48:59.059946| nta.c:3299 agent_recv_response() nta: received 100 Trying for INVITE (108938805)
00001b68|2017-Jun-27 07:48:59.060009| nta.c:3366 agent_recv_response() nta: 100 Trying is going to a transaction
00001b69|2017-Jun-27 07:48:59.060074| nta.c:9564 outgoing_estimate_delay() nta_outgoing: RTT is 7.285 ms
00001b6a|2017-Jun-27 07:48:59.060127| tport.c:4222 tport_release() tport_release(0x2460d00): 0x24c58c0 by 0x24b62b0 with 0x24c8540 (preliminary)
00001b6b|2017-Jun-27 07:48:59.100284| tport.c:2749 tport_wakeup_pri() tport_wakeup_pri(0x2460d00): events IN
00001b6c|2017-Jun-27 07:48:59.100368| tport.c:2864 tport_recv_event() tport_recv_event(0x2460d00)
00001b6d|2017-Jun-27 07:48:59.100393| tport.c:3205 tport_recv_iovec() tport_recv_iovec(0x2460d00) msg 0x24c5370 from (udp/174.31.10.81:5060) has 935 bytes, veclen = 1
00001b6e|2017-Jun-27 07:48:59.100514| recv 935 bytes from udp/[174.31.10.81]:5080 at 07:48:59.100418:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 174.31.10.81;branch=z9hG4bKQ929cy06H1g0H
From: <sip:174.31.10.81>;tag=tgUpHBrDgNZ1r
To: <sip:[email protected]:5080>;tag=rDa0KvHBFQv5N
Call-ID: eb9e2d9b-d5af-1235-d09c-0ac4d0dfda04
CSeq: 108938805 INVITE
Contact: <sip:[email protected]:5080;transport=udp>
User-Agent: drachtio MRF
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY
Supported: path, replaces
Allow-Events: talk, hold, conference, refer
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 242
Remote-Party-ID: "drachtio" <sip:[email protected]>;party=calling;privacy=off;screen=no

v=0
o=FreeSWITCH 1498522911 1498522912 IN IP4 174.31.10.81
s=FreeSWITCH
c=IN IP4 174.31.10.81
t=0 0
m=audio 26828 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
m=video 0 RTP/AVP 19 
00001b6f|2017-Jun-27 07:48:59.100543| tport.c:3023 tport_deliver() tport_deliver(0x2460d00): msg 0x24c5370 (935 bytes) from udp/174.31.10.81:5060 next=(nil)
00001b70|2017-Jun-27 07:48:59.100557| nta.c:3299 agent_recv_response() nta: received 200 OK for INVITE (108938805)
00001b71|2017-Jun-27 07:48:59.100571| nta.c:3366 agent_recv_response() nta: 200 OK is going to a transaction
00001b72|2017-Jun-27 07:48:59.100582| tport.c:4222 tport_release() tport_release(0x2460d00): 0x24c58c0 by 0x24b62b0 with 0x24c5370
00001b73|2017-Jun-27 07:48:59.100595| SipDialogController::processResponse - adding dialog id: 4e4c6eba-decf-4c50-bcd0-eb89ad4c3ce5
00001b74|2017-Jun-27 07:48:59.100617| ClientController::addDialogForTransaction - added dialog (uac), now tracking: 16 dialogs and 1 app transactions
00001b75|2017-Jun-27 07:48:59.102653| nta.c:2665 nta_tpn_by_url() nta: selecting scheme sip
00001b76|2017-Jun-27 07:48:59.102698| tport.c:3257 tport_tsend() tport_tsend(0x2460d00) tpn = udp/174.31.10.81:5080
00001b77|2017-Jun-27 07:48:59.102720| tport.c:4046 tport_resolve() tport_resolve addrinfo = 174.31.10.81:5080
00001b78|2017-Jun-27 07:48:59.102733| tport.c:4680 tport_by_addrinfo() tport_by_addrinfo(0x2460d00): not found by name udp/174.31.10.81:5080
00001b79|2017-Jun-27 07:48:59.102924| tport.c:3492 tport_send_msg() tport_vsend returned 324
00001b7a|2017-Jun-27 07:48:59.102978| send 324 bytes to udp/[174.31.10.81]:5080 at 07:48:59.102758:
ACK sip:[email protected]:5080;transport=udp SIP/2.0
Via: SIP/2.0/UDP 174.31.10.81;branch=z9hG4bKrjv2eSHaFa7jD
Max-Forwards: 70
From: <sip:174.31.10.81>;tag=tgUpHBrDgNZ1r
To: <sip:[email protected]:5080>;tag=rDa0KvHBFQv5N
Call-ID: eb9e2d9b-d5af-1235-d09c-0ac4d0dfda04
CSeq: 108938805 ACK
Content-Length: 0
 
00001b7b|2017-Jun-27 07:48:59.103013| nta.c:8304 outgoing_send() nta: sent ACK (108938805) to udp/174.31.10.81:5080
00001b7c|2017-Jun-27 07:48:59.117034| nta.c:1348 set_timeout() nta: timer shortened to 200 ms
00001b7d|2017-Jun-27 07:48:59.117096| nta.c:4417 nta_leg_tcreate() nta_leg_tcreate(0x24c6af0)
00001b7e|2017-Jun-27 07:48:59.117162| tport.c:3257 tport_tsend() tport_tsend(0x2460d00) tpn = UDP/83.56.45.209:5060
00001b7f|2017-Jun-27 07:48:59.117186| tport.c:4046 tport_resolve() tport_resolve addrinfo = 83.56.45.209:5060
00001b80|2017-Jun-27 07:48:59.117199| tport.c:4680 tport_by_addrinfo() tport_by_addrinfo(0x2460d00): not found by name UDP/83.56.45.209:5060
00001b81|2017-Jun-27 07:48:59.117425| tport.c:3492 tport_send_msg() tport_vsend returned 599
00001b82|2017-Jun-27 07:48:59.117503| send 599 bytes to udp/[83.56.45.209]:5060 at 07:48:59.117405:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.9.54:5060;rport=5060;branch=z9hG4bK1186645242;received=83.56.45.209
From: "GetFace IP" <sip:[email protected]>;tag=1705390330
To: <sip:[email protected]>;tag=USmFK68gDyNmm
Call-ID: 1001992504
CSeq: 20 INVITE
Contact: <sip:174.31.10.81>
Content-Type: application/sdp
Content-Length: 254

v=0
o=FreeSWITCH 1498522911 1498522912 IN IP4 174.31.10.81
s=FreeSWITCH
c=IN IP4 174.31.10.81
t=0 0
m=audio 26828 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
m=video 0 RTP/AVP 19 
00001b83|2017-Jun-27 07:48:59.117525| nta.c:6791 incoming_reply() nta: sent 200 OK for INVITE (20)
00001b84|2017-Jun-27 07:48:59.317051| nta.c:1296 agent_timer() nta: timer set next to 4801 ms
00001b85|2017-Jun-27 07:49:04.121929| nta.c:7134 _nta_incoming_timer() nta: timer I fired, terminate 200 response
00001b86|2017-Jun-27 07:49:04.122011| nta.c:7188 _nta_incoming_timer() nta_incoming_timer: 0/0 resent, 0/0 tout, 1/1 term, 0/30 free
00001b87|2017-Jun-27 07:49:04.122030| nta.c:1296 agent_timer() nta: timer set next to 11472 ms
00001b88|2017-Jun-27 07:49:13.266840| size of hash table for dialogs                                   63
00001b89|2017-Jun-27 07:49:13.266922| number of server-side transactions in the hash table             30
00001b8a|2017-Jun-27 07:49:13.266937| number of client-side transactions in the hash table             4
00001b8b|2017-Jun-27 07:49:13.266947| number of dialogs in the hash table                              21
00001b8c|2017-Jun-27 07:49:13.266956| number of sip messages received                                  184
00001b8d|2017-Jun-27 07:49:13.266965| number of sip messages sent                                      71
00001b8e|2017-Jun-27 07:49:13.266974| number of sip requests received                                  150
00001b8f|2017-Jun-27 07:49:13.266982| number of sip requests sent                                      34
00001b90|2017-Jun-27 07:49:13.267008| number of in-dialog server transactions created                  13
00001b91|2017-Jun-27 07:49:13.267020| number of SIP requests sent by stack                             34
00001b92|2017-Jun-27 07:49:13.267029| number of SIP responses sent by stack                            37
00001b93|2017-Jun-27 07:49:13.267037| number of SIP requests retransmitted by stack                    0
00001b94|2017-Jun-27 07:49:13.267046| number of SIP responses retransmitted by stack                   0
00001b95|2017-Jun-27 07:49:13.267054| number of retransmitted SIP requests received by stack           117
00001b96|2017-Jun-27 07:49:13.267069| SipProxyController storage counts
00001b97|2017-Jun-27 07:49:13.267090| ----------------------------------
00001b98|2017-Jun-27 07:49:13.267100| m_mapCallId2Proxy size:                                          0
00001b99|2017-Jun-27 07:49:13.267109| general queue size:                                              0
00001b9a|2017-Jun-27 07:49:13.267118| timer A queue size:                                              0
00001b9b|2017-Jun-27 07:49:13.267126| timer B queue size:                                              0
00001b9c|2017-Jun-27 07:49:13.267134| timer C queue size:                                              0
00001b9d|2017-Jun-27 07:49:13.267142| timer D queue size:                                              0
00001b9e|2017-Jun-27 07:49:13.267151| timer E queue size:                                              0
00001b9f|2017-Jun-27 07:49:13.267159| timer F queue size:                                              0
00001ba0|2017-Jun-27 07:49:13.267167| timer K queue size:                                              0

and my-drachtio process code is:

var drachtio = require('drachtio') ;
var app = drachtio();
var Mrf = require('drachtio-fsmrf'); 
var mrf = new Mrf(app) ;
var Srf = require('drachtio-srf'); 
var srf = new Srf(app) ;

srf.connect({
  host: '127.0.0.1',
  port: 9022,
  secret: 'cymru',
}) 
.on('connect', (err, hostport) => { console.log(`connected to drachtio listening on ${hostport}`) ;})
.on('error', (err) => { console.error(`Error connecting to drachtio at ${err || err.message}`) ; }) ;


mrf.connect( {
  address: '127.0.0.1',
  port: 8021,
  secret: 'ClueCon',
  listenPort: 8085
}, (ms) => {
  console.log(`connected to media server `);
  // save the media server object as in app locals so it can be retrieved from middleware
  srf.locals.ms = ms ;
}) ;




srf.invite( (req, res) => {
  
 
   console.log("Invitation received!");
 // connect caller to an endpoint on the media server
  req.app.locals.ms.connectCaller(req, res, {
    codecs: ['PCMU', 'PCMA', 'OPUS','G722']
 }, (err, ep, dialog) => {

    console.log("Connect caller!");

    if( err ) { throw err ; }

    // set up dialog handlers
    dialog.on('destroy', () => { ep.destroy() ; }) ;

    // play some prompts
    ep.play(['ivr/8000/ivr-please_reenter_your_pin.wav',
      'ivr/8000/ivr-please_state_your_name_and_reason_for_calling.wav',
      'ivr/8000/ivr-you_lose.wav'], function(err, results){
        console.log(`results: ${JSON.stringify(results)}`) ;
      }) ;
  }) ; 
}) ;

Thanks,

conference.startRecording Crash

Howdy Dave!

I've found that using conference.startRecording crashes due to this regex not properly handling the result. When I run it, I get a result like this:

Error: +OK Record file rtmp://XXX.YYY/ZZZ/05f7cda210ff4ea49122aea69ae595b3 canvas 1
Notice the +OK. That seems to trip up your regex which causes the crash.

Freeswitch does start recording the file, its just that FSMRF detects it as an error.

No playback on FreeSWITCH side after endpoint.play()

I tried to implement simple case with file play on incoming call. I started two containers:

docker run -d --rm --name srf --net=host drachtio/drachtio-server:latest drachtio --contact "sip:*;transport=udp"
docker run -d --rm --name mrf --net=host drachtio/drachtio-freeswitch-mrf freeswitch

Next I started my application:

const Srf = require('drachtio-srf')
const srf = new Srf()
const Mrf = require('drachtio-fsmrf')
const mrf = new Mrf(srf)

srf.connect({ host: '127.0.0.1', port: 9022, secret: 'cymru' })

srf.on('connect', (err, endpoint) => { console.log(`Connected to a drachtio server listening on: ${endpoint}`) })
srf.on('error', (err) => { console.log(`Error connecting to drachtio server: ${err}`) })

srf.invite(async(req, res) => {
  try {
    const ms = await mrf.connect({ address:'127.0.0.1', port: 8021, secret: 'ClueCon'})
    const {endpoint, dialog} = await ms.connectCaller(req, res)
    console.log('Call connected')
    dialog.on('destroy', () => {
      console.log('Call ended')
      endpoint.destroy()
    })
    const event = await endpoint.play('/usr/local/freeswitch/sounds/welcome.wav')
    console.log(`Media event: ${JSON.stringify(event)}`)
    console.log('Finished playing')
  } catch (err) {
    console.log(err)
  }
})

On incoming call I see:

Call connected
Media event: {"playbackSeconds":"1","playbackMilliseconds":"1190"}
Finished playing
Call ended

But I see no playback attempts in FreeSWITCH console via docker logs -f mrf and no sound on other side of incoming call.

What is wrong?

Detected-Tone or Detected-Fax-Tone events not available

  _onToneDetect(evt) {
    let tone = evt.getHeader('Detected-Tone');
    if (!tone && evt.getHeader('Detected-Fax-Tone') === 'true') tone = 'fax';
    this.emit('tone', {tone});
  }

I can see this code but even when a call or fax received to number using a SIP trunk that supports T.30 protocol like Twilio nothing is triggering this event. How could one handle fax received using Freeswitch ESL from the drachtio-fsmrf module?

thanks!

mediaserver connection timeout

Hello Dave,

My app is UAS and drachtio-fsmrf sends 200 OK to remote sip server internally even if freeswitch connection has timed out(connectCaller or createEndpoint). So my app has no way to disconnect(sending bye) because drachtio-fsmrf does not return any dialog or endpoint object, just throw error callback.

Is there any way to resolve this?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.