drachtio / drachtio-siprec-recording-server

SIPREC recording server based on drachtio and rtpengine
MIT License
83 stars 34 forks source link

OpenSIPS returns bye to drachtio prior to call ending with freeswitch backend #3

Closed franzene closed 5 years ago

franzene commented 5 years ago

Im using freeswitch as the recording server Ive been able to get everything mostyl working, freeswitch will start to create a recording file but once opensips receives the 200 OK SDP from drachtio it returns BYE. Im not sure if this issue is an opensips configuration issue or drachtio but I was hoping you might know.

Ive included a wireshark screenshot of the transaction. Green: base call between client/opensips/rtpproxy/asterisk pink&tan: drachtio/freeswitch orange: drachtio/opensips

image

franzene commented 5 years ago

Just realised opensips is throwing an error, so its likely not an issue wiht drachtio.

opensips_1        | Dec 11 22:11:51 opensips /usr/local/sbin/opensips[54]: ERROR:siprec:srs_handle_media: SDP stream not processed for [m=audio 24804 RTP/AVP 0 101#015#012a=rtpmap:0 PCMU/8000#015#012a=rtpmap:101 telephone-event/8000#015#012a=fmtp:101 0-16#015#012a=recvonly#015#012a=ptime:20#015#012a=ice-ufrag:yytLZ15Zv7EfYHkD#015#012a=ice-pwd:UtYPsef2gEL1wFRU4avU2qKo#015#012a=candidate:0041956539 1 udp 659136 172.18.0.8 24804 typ host generation 0#015#012a=candidate:0041956539 2 udp 659135 172.18.0.8 24805 typ host generation 0#015#012a=end-of-candidates#015#012a=ssrc:3155441287 cname:Oniv59qzKcySU14Z#015#012a=ssrc:3155441287 msid:wWkcRR14ELV8iSDlfGEDmBIuaEcOT1cf a0#015#012a=ssrc:3155441287 mslabel:wWkcRR14ELV8iSDlfGEDmBIuaEcOT1cf#015#012a=ssrc:3155441287 label:wWkcRR14ELV8iSDlfGEDmBIuaEcOT1cfa0#015#012]
opensips_1        | Dec 11 22:11:51 opensips /usr/local/sbin/opensips[54]: ERROR:siprec:srec_b2b_notify: cannot handle SRS media!
davehorton commented 5 years ago

Can you include the drachtio log file (complete)? I'd like to see the SDP that is being sent / received and it is difficult to see that in the wireshark image. Alternatively you can send the entire wireshark pcap

franzene commented 5 years ago

drachtio https://pastebin.com/1jsL7cas freeswitch https://pastebin.com/0JjPk4wL

franzene commented 5 years ago

tmp.pcapng.zip

davehorton commented 5 years ago

The problem is that your opensips is offering an SDP that says media is going to come from 127.0.0.1 - localhost. You need to configure opensips to be offering to send media from a "real" address that is reachable by the Freeswitch. This seems like your setup is not a realistic real-world setup

franzene commented 5 years ago

Thanks!, I probably would have never figured that out. I must have misconfigured the siprec modules as the rest of the call seems to work.

franzene commented 5 years ago

I updated opensips to use rtpproxy's ip instead of 127.0.0.1, doesnt seem to change anything. Im thinking the issue is either with my opensips cfg or with the response by drachtio. Opensips is thowing an error here: https://github.com/OpenSIPS/opensips/blob/master/modules/siprec/siprec_body.c#L706

davehorton commented 5 years ago

can I see an updated drachtio log?

franzene commented 5 years ago

https://pastebin.com/RWAiAGHx

davehorton commented 5 years ago

At this point it does seem like an opensips or rtpproxy problem. I would try configuring rtpproxy to not insert the ICE candidates - i.e just offer a plan simple SDP payload.

franzene commented 5 years ago

Hmm thanks for the help! What's the difference between this project and https://github.com/davehorton/drachtio-srs-freeswitch/ the latter seems simpler as there is no redis server.

davehorton commented 5 years ago

That was an earlier version, which also works but was not as well documented. The reason for the redis dependency here is so that if needed you could scale beyond a single SIP drachtio server I believe.

franzene commented 5 years ago

I was able to figure out the issue, opensips was expecting the sdp metadata to be attached when responding to the invite. I was able to get the drachtio-srs-freeswitch project to work by modifying this line https://github.com/davehorton/drachtio-srs-freeswitch/blob/master/app.js#L67 to return fullSdp.

davehorton commented 5 years ago

that's interesting could you possibly include a drachtio log of the now-working scenario so I can examine to see if its a bug I need to fix?

franzene commented 5 years ago

My success was just a fluke/luck as I cant get freeswitch to record the streams again, I think it was just luck with the port mappings. however I believe opensips requires the metadata to be returned as it looks for the session & stream here https://github.com/OpenSIPS/opensips/blob/master/modules/siprec/siprec_body.c#L706

franzene commented 5 years ago

If i can get a successful transaction ill port the drachtio log

franzene commented 5 years ago

this is the drachtio log from a successfull call & recording. https://pastebin.com/ws0bdqxp using srs-freeswitch, it doesnt work reliably, seems some luck is required for the ports to line up.

franzene commented 5 years ago

https://github.com/davehorton/drachtio-srs-freeswitch/blob/master/app.js#L67 I had to use fullSdp here to get opensips to not return a BYE. fullSdp

v=0
o=- 1544651022 0 IN IP4 0.0.0.0
s=-
t=0 0
c=IN IP4 172.18.0.4
m=audio 58001 RTP/AVP 0 8 101
a=ice-pwd:db01578168d63cba22296265
a=ice-ufrag:49126a8f
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
a=rtpmap:101 telephone-event/8000
a=rtcp:56315
a=candidate:1 1 UDP 2130706431 192.168.1.23 53430 typ host
a=candidate:1 2 UDP 2130706430 192.168.1.23 56315 typ host
a=candidate:2 1 UDP 1694498815 100.10.14.55 53430 typ srflx raddr 192.168.1.23 rport 53430
a=candidate:2 2 UDP 1694498814 100.10.14.55 56315 typ srflx raddr 192.168.1.23 rport 56315
a=rtcp-fb:* trr-int 5000
a=rtcp-fb:* ccm tmmbr
a=label:1
a=sendonly
m=audio 58002 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=label:2
a=sendonly
info: B2B.312.172849.1544651022: SIPREC call legs established
info: B2B.312.172849.1544651022: SIPREC terminated by SRC

sdp

v=0
o=FreeSWITCH 1544586372 1544586373 IN IP4 172.18.0.6
s=FreeSWITCH
t=0 0
c=IN IP4 172.18.0.6
m=audio 64650 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=recvonly
a=ptime:20
a=ice-ufrag:KUIqHDy7qxWkk1FU
a=ice-pwd:cfXKVq1CMdvIEspfdXvKrUHH
a=candidate:8016577822 1 udp 659136 172.18.0.6 64650 typ host generation 0
a=candidate:8016577822 2 udp 659135 172.18.0.6 64651 typ host generation 0
a=end-of-candidates
a=ssrc:1880457086 cname:JlJcHQDqQvm25A7Q
a=ssrc:1880457086 msid:BWgoCwgBTa25mJoeVjX1QW5hzX8Z3Xev a0
a=ssrc:1880457086 mslabel:BWgoCwgBTa25mJoeVjX1QW5hzX8Z3Xev
a=ssrc:1880457086 label:BWgoCwgBTa25mJoeVjX1QW5hzX8Z3Xeva0
m=audio 64698 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=recvonly
a=ptime:20
davehorton commented 5 years ago

it looks like part of the issue is that it wants that a:label attribute in the SDP. Let me push a branch with that and you can test against.

Does opensips always burp up that same error message (corresponding to the line of code you pointed to earlier) or does it sometimes seem to fail for other reasons?

franzene commented 5 years ago

Yeah I always get the same 2 opensips errors that I posted above.

davehorton commented 5 years ago

I pushed a branch in this repo called 'opensips-label-fix' with a small change for this. Can you test it?

franzene commented 5 years ago

that seems to have fixed the opensips errors, freeswitch stays up for the full call now.

davehorton commented 5 years ago

ok, and you are able to get a recording? Is everything working ok now ?

davehorton commented 5 years ago

I merged that branch so that the master branch now has the fix as well. Please go ahead and close the issue if you are good, otherwise update with details

franzene commented 5 years ago

I think i am good I have one stream recording now, Ill have to look into why the other isnt being captured but thats likely a networking issue(hopefully). Thanks for all the help!

richnayay commented 5 years ago

Hi Dave Facing similar issue. Can you please have a look at the logs drachtio.log drachtio_recorder.txt dracthio.zip opensips-file.zip opensips-log-siprec.zip

richnayay commented 5 years ago

local.json { "drachtio": { "host": "127.0.0.1", "port": 9022, "secret": "cymru" }, "freeswitch" : ["167.99.54.110"], "redis" : { "host": "54.160.157.91", "port": 6379 } } public.xml

<?xml version="1.0" encoding="utf-8"?>

davehorton commented 5 years ago

Hmm, I'm guessing that in the last fix I made for you I caused a regression by leaving out the change from the 'opensips-label-fix' branch. Will check into this..

davehorton commented 5 years ago

I've pushed a fix on the branch 'opensips-fix2'. Could you possibly test this for me in your environment before I merge it and let me know the results?

richnayay commented 5 years ago

It's working now. thanks

richnayay commented 5 years ago

Can you please tell me where to find the metadata file in case of freeswitch as media server. as it is not present in recording directory

davehorton commented 5 years ago

Freeswitch does not generate a meta data file. That's a feature of rtpengine, but not freeswitch.

solarmon commented 5 years ago

Hi,

Apologies for resurrecting this closed ticket, and I wasn't sure whether to open a new one or not, but I didn't want to open a duplicate ticket.

I have a similar issue using the latest drachtio-siprec-recording-server build. I have an OpenSIPS 2.4 setup (with mod_siprec and rtpproxy) acting as the SRC (212.161.103.203), and I have set up Drachtio with rtpengine as the SRS (212.161.103.198).

I am seeing the same OpenSIPS behaviour and error message whereby the OpenSIPS server is clearing down with an ACK and BYE immediately after it receives back a 200 OK (SDP) from Drachtio:

                                           Call flow for B2B.436.1555101.1554731153 (Color by Request/Response)
                                                            │SIP/2.0 200 OK
           212.161.103.203:5060          212.161.103.198:506│Via: SIP/2.0/UDP 212.161.103.203:5060;branch=z9hG4bK87e6.26d047f5.0;rport=5060
          ──────────┬─────────          ──────────┬─────────│From: <sip:212.161.103.198:5060>;tag=ab4a1a9184a3756688fb9d8cb2be795b-ce21
  14:45:54.411616   │        INVITE (SDP)         │         │To: <sip:212.161.103.198:5060>;tag=7Xjcr531HjSZr
        +0.000811   │ ──────────────────────────> │         │Call-ID: B2B.436.1555101.1554731153
  14:45:54.412427   │         100 Trying          │         │CSeq: 2 INVITE
        +0.014785   │ <────────────────────────── │         │Contact: <sip:212.161.103.198:5060>
  14:45:54.427212   │        200 OK (SDP)         │         │Content-Type: application/sdp
        +0.000228   │ <────────────────────────── │         │Content-Length: 368
  14:45:54.427440   │             ACK             │         │
        +0.000084   │ ──────────────────────────> │         │v=0
  14:45:54.427524   │             BYE             │         │o=- 1554731154 0 IN IP4 0.0.0.0
        +0.043763   │ ──────────────────────────> │         │s=-
  14:45:54.471287   │           200 OK            │         │c=IN IP4 212.161.103.198
                    │ <────────────────────────── │         │t=0 0
                    │                             │         │m=audio 31034 RTP/AVP 8 0 101
                    │                             │         │a=rtpmap:8 PCMA/8000
                    │                             │         │a=rtpmap:0 PCMU/8000
                    │                             │         │a=rtpmap:101 telephone-event/8000
                    │                             │         │a=fmtp:101 0-15
                    │                             │         │a=rtcp:31035
                    │                             │         │a=label:1
                    │                             │         │m=audio 31054 RTP/AVP 8 101
                    │                             │         │a=rtpmap:8 PCMA/8000
                    │                             │         │a=rtpmap:101 telephone-event/8000
                    │                             │         │a=fmtp:101 0-16
                    │                             │         │a=rtcp:31055
                    │                             │         │a=ptime:20
                    │                             │         │a=label:2

Initially, I had the same "c=IN IP4 127.0.0.1" issue, but that was resolved. However, I'm still getting this immediate BYE teardown issue.

I see that the "a:label" fields has been returned, but this still seems to be an issue for me.

What further info/logs do you require to be able to diagnose this issue further?

solarmon commented 5 years ago

Hi,

Just a follow up on my issue. This issue is actually on the OpenSIPS side. I noticed that there were such error logs on OpenSIPS:

ERROR:rtpproxy:rtpproxy_api_recording: no available proxies
ERROR:siprec:srs_handle_media: cannot start recording for stream 0x7fecc7fce278 (label=2)
ERROR:rtpproxy:select_rtpp_node: no set specified
ERROR:rtpproxy:rtpproxy_api_recording: no available proxies
ERROR:siprec:srs_handle_media: cannot start recording for stream 0x7fecc7fcb990 (label=1)
ERROR:siprec:srec_b2b_notify: cannot handle SRS media!

For some reason, it was not finding an appropriate rtpproxy node to use for the media SIPREC streams, even though it is found for the normal call legs. It was not until I set a default proxy set in opensips.cfg that it started working:

modparam("rtpproxy", "default_set", 1)

I will raise a ticket on the OpenSIPS side to determine whether this is the expected behaviour and configuration.

davehorton commented 5 years ago

ok, thanks - good to know

kietcaodev commented 1 year ago

@franzene , hello, can you suggest me OS and version, easy install drachtio-siprec-recording-server. Many thanks