drachtio / drachtio-siprec-recording-server

SIPREC recording server based on drachtio and rtpengine
MIT License
80 stars 30 forks source link

can not use local freeswitch #54

Open fabian-borot opened 1 year ago

fabian-borot commented 1 year ago

I set up the drachtio-siprec app, the drachtio sip server and the freeswitch (FS) on the same machine. FS uses UDP 5080 and the drachtio server uses UDP 5060. When receiving a call the app complains: "can not send request to myself"

{"level":30,"time":1662675450965,"msg":"received SIPREC invite: sip:10.134.4.199:5060","pid":308169,"hostname":"ip-10-134-4-199","callid":"c37c3f91c4da6346144b3f8af6586ea4@10.134.4.199","v":1} {"level":50,"time":1662675450983,"msg":"can not send request to myself Error connecting incoming SIPREC call to freeswitch","pid":308169,"hostname":"ip-10-134-4-199","callid":"c37c3f91c4da6346144b3f8af6586ea4@10.134.4.199","v":1} (node:308169) UnhandledPromiseRejectionWarning: can not send request to myself can they be on the same server ? what is the recommended set up? Txs!

fabian-borot commented 1 year ago

this section in the drachtio-server is the one that rejects the call:

            //prevent looping messages
            normalizeSipUri( requestUri, 0 ) ;
            if( isLocalSipUri( requestUri ) ) {
                throw std::runtime_error("can not send request to myself") ;
            }
davehorton commented 1 year ago

that should only be the case if it is sending to a port that it is listening on (ie not allowed to loop a message to its own address:port)

fabian-borot commented 1 year ago

it seems so, I had the config/local.json file like this:

{ "drachtio": { "host": "127.0.0.1", "port": 9022, "secret": "cymru" }, "freeswitch" : ["10.X.Y.Z"], "redis" : { "host": "127.0.0.1", "port": 6379 } }

I changed it to this hoping the port setting works to avoid the loop:

{ "drachtio": { "host": "127.0.0.1", "port": 9022, "secret": "cymru" }, "freeswitch" : ["10.X.Y.Z:5080"], "redis" : { "host": "127.0.0.1", "port": 6379 } }

now I see the drachtio do send the INVITE to the FS, the FS replies with 480 though, I applied the code snippet (hairpin) to the dialplan.xml as suggested by the instructions:

`2022-09-09 13:36:35.194718 send 822 bytes to udp/[10.X.Y.Z]:5080 at 13:36:35.194635: INVITE sip:+13055886662@10.X.Y.Z:5080 SIP/2.0

2022-09-09 13:36:35.202620 recv 735 bytes from udp/[10.X.Y.Z]:5080 at 13:36:35.202514: SIP/2.0 480 Temporarily Unavailable`

First time using FS, any idea? Much appreciated

fabian-borot commented 1 year ago

disregard my last comment, I put the code snippet in the wrong xml file (default.xml) , I put it now on the public.xml and now the call is received/accepted . I am having an issue with the codecs ( replied with 488) I need to see why, I am a complete newbie to FS but it should not be too hard to figure out. The only thing that I would add is that the nodejs app handling the SIPREC does not like the Reject SIP responses and there is always a bit of a complain with every negative SIP response, It seems it is not expected

(node:310950) UnhandledPromiseRejectionWarning: SipError: Sip non-success response: 488 at Request.<anonymous> (/home/ubuntu/drachtio-siprec-recording-server/node_modules/drachtio-srf/lib/srf.js:596:29) at Request.emit (events.js:314:20) at DrachtioAgent._onMsg (/home/ubuntu/drachtio-siprec-recording-server/node_modules/drachtio-srf/lib/drachtio-agent.js:680:22) at WireProtocol.emit (events.js:314:20) at WireProtocol.processMessageBuffer (/home/ubuntu/drachtio-siprec-recording-server/node_modules/drachtio-srf/lib/wire-protocol.js:270:12) at WireProtocol._onData (/home/ubuntu/drachtio-siprec-recording-server/node_modules/drachtio-srf/lib/wire-protocol.js:304:14) at Socket.emit (events.js:314:20) at addChunk (_stream_readable.js:297:12) at readableAddChunk (_stream_readable.js:268:11) at Socket.Readable.push (_stream_readable.js:213:10) (node:310950) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 13)

once I have this SIPREC working I will look into that. other than that txs a lot!