drachtio / drachtio-server

A SIP call processing server that can be controlled via nodejs applications
https://drachtio.org
MIT License
237 stars 92 forks source link

SIP over TCP + DNS #301

Open two56 opened 1 year ago

two56 commented 1 year ago

Reproduce issue:

Behaviour:

Some calls are hung up due to the ACK not being recognised by the UAS (T1x64 timer firing), I believe this is down to the Via header having the wrong transport (UDP instead of TCP).

Once DNS has been resolved and cached, subsequent calls are successful until the cache times out.

As far as I can tell, the orq returned by sofia-sip, when creating a request and DNS has to be resolved, doesn't contain transport. When 200 OK is returned from the UAS and the dialog is created, transport is missing so isn't passed in when responding with the ACK.

I've put a small patch in to sip-dialog-controller.cpp to set the transport on the dialog if it's missing, which seems to fix the issue. Although I'm fairly sure it isn't the right thing to do.

diff --git a/src/sip-dialog-controller.cpp b/src/sip-dialog-controller.cpp
index 2642dcc8ca..ed544774dc 100644
--- a/src/sip-dialog-controller.cpp
+++ b/src/sip-dialog-controller.cpp
@@ -805,6 +805,9 @@ namespace drachtio {
                 addDialog( dlg ) ;
             }
             tport_t* tp = nta_outgoing_transport(orq);
+            if (!dlg->getTport()) {
+              dlg->setTport(tp);
+            }
             if (sip->sip_cseq->cs_method == sip_method_invite && sip->sip_status->st_status == 200 && tport_is_dgram(tp)) {
                 // for successful uac invites, we need to handle retransmits
                 m_timerDHandler.addInvite(orq);

Drachtio log attached (Call-ID: 7d99d2c6-9671-123c-4c99-067aa53d80b5)

drachtio.log