drachtio/drachtio-server

Sending binary messages

cchiaramelli opened this issue · 5 comments

Hi there,

I'm trying to use Drachtio server to handle incoming binary messages of Content-Type=application/vnd.3gpp.sms. Unfortunately, my SIP Agent (drachtio-srf) is never called.

The logs after a single message sent using sipp:

scripts-drachtio-1             | 2023-03-04 14:32:02.028271 tport.c:2806 tport_wakeup_pri() tport_wakeup_pri(0x563c25c0c500): events IN
scripts-drachtio-1             | 2023-03-04 14:32:02.028301 tport.c:2929 tport_recv_event() tport_recv_event(0x563c25c0c500)
scripts-drachtio-1             | 2023-03-04 14:32:02.028311 tport.c:3270 tport_recv_iovec() tport_recv_iovec(0x563c25c0c500) msg 0x563c25c2d000 from (udp/99.0.0.6:5060) has 739 bytes, veclen = 1
scripts-drachtio-1             | 2023-03-04 14:32:02.028367 recv 739 bytes from udp/[99.0.0.1]:44842 at 14:32:02.028318:
scripts-drachtio-1             | MESSAGE sip:127.0.0.1 SIP/2.0
scripts-drachtio-1             | Via: SIP/2.0/UDP 127.0.0.1:5061;branch=z9hG4bK-1166580-1-0
scripts-drachtio-1             | From: <sip:scscf1.home1.net>;tag=1166580SIPpTag001
scripts-drachtio-1             | To: <sip:user1_public1@home1.net>
scripts-drachtio-1             | Call-ID:1-1166580@127.0.0.1
scripts-drachtio-1             | CSeq: 1 MESSAGE
scripts-drachtio-1             | Contact: <sip:scscf1.home1.net>
scripts-drachtio-1             | Max-forwards: 69
scripts-drachtio-1             | P-Access-Network-Info: IEEE-802.11;"location-info=10.213.33.147"
scripts-drachtio-1             | P-Asserted-Identity: <sip:10.5.0.1:5090>
scripts-drachtio-1             | P-Asserted-Identity: tel:+5547987922201
scripts-drachtio-1             | P-Visited-Network-ID: "Visited network number 1"
scripts-drachtio-1             | P-Charging-Vector: icid-value="3cd05a10-2cf4-11e8-a49e-10604baee9cc"
scripts-drachtio-1             | P-Charging-Function-Addresses: ccf=192.0.8.1; ecf=192.0.8.3
scripts-drachtio-1             | User-agent: SIPP-TESTER
scripts-drachtio-1             | Expires: 600000
scripts-drachtio-1             | Content-Type: application/vnd.3gpp.sms
scripts-drachtio-1             | Content-Length:    27
scripts-drachtio-1             |  
scripts-drachtio-1             | 2023-03-04 14:32:02.028372    *** message truncated at 712 ***
scripts-drachtio-1             | 2023-03-04 14:32:02.028377 tport.c:3088 tport_deliver() tport_deliver(0x563c25c0c500): msg 0x563c25c2d000 (739 bytes) from udp/99.0.0.1:5060 next=(nil)
scripts-drachtio-1             | 2023-03-04 14:32:02.028380 tport.c:1171 tport_ref() tport_ref(0x563c25c0c500): refcount is now 2
scripts-drachtio-1             | 2023-03-04 14:32:02.028386 nta.c:3046 agent_recv_request() nta: received MESSAGE sip:127.0.0.1 SIP/2.0 (CSeq 1)
scripts-drachtio-1             | 2023-03-04 14:32:02.028391 nta.c:3346 agent_check_request_via() nta: Via check: received=99.0.0.1
scripts-drachtio-1             | 2023-03-04 14:32:02.028398 nta.c:3263 agent_recv_request() nta: MESSAGE (1) to message callback
scripts-drachtio-1             | 2023-03-04 14:32:02.028401 processMessageStatelessly - incoming message with call-id 1-1166580@127.0.0.1 does not match an existing call leg, processed in thread 140415661702848
scripts-drachtio-1             | 2023-03-04 14:32:02.028406 tport.c:1171 tport_ref() tport_ref(0x563c25c0c500): refcount is now 3
scripts-drachtio-1             | 2023-03-04 14:32:02.028408 tport.c:1184 tport_unref() tport_unref(0x563c25c0c500): refcount is now 2
scripts-drachtio-1             | 2023-03-04 14:32:02.028415 ClientController::selectClientForRequestOutsideDialog - there are 1 possible clients, we are starting with offset 0
scripts-drachtio-1             | 2023-03-04 14:32:02.028420 ClientController::route_request_outside_dialog - Selected client at offset 0
scripts-drachtio-1             | 2023-03-04 14:32:02.028423 tport.c:1171 tport_ref() tport_ref(0x563c25c0c500): refcount is now 3
scripts-drachtio-1             | 2023-03-04 14:32:02.028426 tport.c:1184 tport_unref() tport_unref(0x563c25c0c500): refcount is now 2
scripts-drachtio-1             | 2023-03-04 14:32:02.028433 tport.c:1171 tport_ref() tport_ref(0x563c25c0c500): refcount is now 3
scripts-drachtio-1             | 2023-03-04 14:32:02.028436 PendingRequestController::add - tport: 0x563c25c0c500, Call-ID: 1-1166580@127.0.0.1, transactionId 1079e9b3-45eb-4d2b-81d9-326ac474a3eb
scripts-drachtio-1             | 2023-03-04 14:32:02.028440 pending-request: Adding entry to go off in 64000ms
scripts-drachtio-1             | 2023-03-04 14:32:02.028443 pending-request: Adding entry to the tail of the queue: length 2
scripts-drachtio-1             | 2023-03-04 14:32:02.028449 tport.c:1171 tport_ref() tport_ref(0x563c25c0c500): refcount is now 4
scripts-drachtio-1             | 2023-03-04 14:32:02.028452 tport.c:1184 tport_unref() tport_unref(0x563c25c0c500): refcount is now 3
scripts-drachtio-1             | 2023-03-04 14:32:02.028456 ClientController::addNetTransaction: transactionId 1079e9b3-45eb-4d2b-81d9-326ac474a3eb; size: 2
scripts-drachtio-1             | 2023-03-04 14:32:02.028465 tport.c:1184 tport_unref() tport_unref(0x563c25c0c500): refcount is now 2
scripts-drachtio-1             | 2023-03-04 14:32:02.028536 utf8_strlen - code 0x91 at position 888 is not a valid UTF-8 character
scripts-drachtio-1             | 2023-03-04 14:32:02.028550 utf8_strlen - in string: e2d5fce1-2381-4c27-af09-0e3501ad81a8|sip|network|739|udp|99.0.0.1|44842|14:32:02.028448|1079e9b3-45eb-4d2b-81d9-326ac474a3eb||99.0.0.6|5060|
scripts-drachtio-1             | MESSAGE sip:127.0.0.1 SIP/2.0
scripts-drachtio-1             | Via: SIP/2.0/UDP 127.0.0.1:5061;branch=z9hG4bK-1166580-1-0;received=99.0.0.1;rport=44842
scripts-drachtio-1             | From: <sip:scscf1.home1.net>;tag=1166580SIPpTag001
scripts-drachtio-1             | To: <sip:user1_public1@home1.net>
scripts-drachtio-1             | Call-ID:1-1166580@127.0.0.1
scripts-drachtio-1             | CSeq: 1 MESSAGE
scripts-drachtio-1             | Contact: <sip:scscf1.home1.net>
scripts-drachtio-1             | Max-forwards: 69
scripts-drachtio-1             | P-Access-Network-Info: IEEE-802.11;"location-info=10.213.33.147"
scripts-drachtio-1             | P-Asserted-Identity: <sip:10.5.0.1:5090>
scripts-drachtio-1             | P-Asserted-Identity: tel:+5547987922201
scripts-drachtio-1             | P-Visited-Network-ID: "Visited network number 1"
scripts-drachtio-1             | P-Charging-Vector: icid-value="3cd05a10-2cf4-11e8-a49e-10604baee9cc"
scripts-drachtio-1             | P-Charging-Function-Addresses: ccf=192.0.8.1; ecf=192.0.8.3
scripts-drachtio-1             | User-agent: SIPP-TESTER
scripts-drachtio-1             | Expires: 600000
scripts-drachtio-1             | Content-Type: application/vnd.3gpp.sms
scripts-drachtio-1             | Content-Length:    27
scripts-drachtio-1             | 
�Ut���s-drachtio-1             | �U�gE#�
scripts-drachtio-1             | 2023-03-04 14:32:02.028557 Client::send - we are unable to send this message back to cliente2d5fce1-2381-4c27-af09-0e3501ad81a8|sip|network|739|udp|99.0.0.1|44842|14:32:02.028448|1079e9b3-45eb-4d2b-81d9-326ac474a3eb||99.0.0.6|5060|
scripts-drachtio-1             | MESSAGE sip:127.0.0.1 SIP/2.0
scripts-drachtio-1             | Via: SIP/2.0/UDP 127.0.0.1:5061;branch=z9hG4bK-1166580-1-0;received=99.0.0.1;rport=44842
scripts-drachtio-1             | From: <sip:scscf1.home1.net>;tag=1166580SIPpTag001
scripts-drachtio-1             | To: <sip:user1_public1@home1.net>
scripts-drachtio-1             | Call-ID:1-1166580@127.0.0.1
scripts-drachtio-1             | CSeq: 1 MESSAGE
scripts-drachtio-1             | Contact: <sip:scscf1.home1.net>
scripts-drachtio-1             | Max-forwards: 69
scripts-drachtio-1             | P-Access-Network-Info: IEEE-802.11;"location-info=10.213.33.147"
scripts-drachtio-1             | P-Asserted-Identity: <sip:10.5.0.1:5090>
scripts-drachtio-1             | P-Asserted-Identity: tel:+5547987922201
scripts-drachtio-1             | P-Visited-Network-ID: "Visited network number 1"
scripts-drachtio-1             | P-Charging-Vector: icid-value="3cd05a10-2cf4-11e8-a49e-10604baee9cc"
scripts-drachtio-1             | P-Charging-Function-Addresses: ccf=192.0.8.1; ecf=192.0.8.3
scripts-drachtio-1             | User-agent: SIPP-TESTER
scripts-drachtio-1             | Expires: 600000
scripts-drachtio-1             | Content-Type: application/vnd.3gpp.sms
scripts-drachtio-1             | Content-Length:    27
scripts-drachtio-1             | 
�Ut���s-drachtio-1             | �U�gE#�

The sipp scenario file:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="UAC with REGISTER">

  <send retrans="1500">
    <![CDATA[
MESSAGE sip:[remote_ip] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:scscf1.home1.net>;tag=[pid]SIPpTag00[call_number]
To: <sip:user1_public1@home1.net>
Call-ID:[call_id]
CSeq: 1 MESSAGE
Contact: <sip:scscf1.home1.net>
Max-forwards: 69
P-Access-Network-Info: IEEE-802.11;"location-info=10.213.33.147"
P-Asserted-Identity: <sip:10.5.0.1:5090>
P-Asserted-Identity: tel:+5547987922201
P-Visited-Network-ID: "Visited network number 1"
P-Charging-Vector: icid-value="3cd05a10-2cf4-11e8-a49e-10604baee9cc"
P-Charging-Function-Addresses: ccf=192.0.8.1; ecf=192.0.8.3
User-agent: SIPP-TESTER
Expires: 600000
Content-Type: application/vnd.3gpp.sms
Content-Length: [len]

\x00\x01\x00\x07\x91\x55\x89\x67\x45\x23\xF1\x10\x00\x01\x00\x0D\x91\x55\x74\x89\x97\x02\x00\xF1\x00\x00\x00]]>
  </send>

  <recv response="202">
  </recv>

  <pause milliseconds="5000"/>

It's important to notice that

  • the body is that binary \x00\x01\x00\x07\x91\x55\x89\x67\x45\x23\xF1\x10\x00\x01\x00\x0D\x91\x55\x74\x89\x97\x02\x00\xF1\x00\x00\x00
  • the drachtio logs show a messed up body "�U�gE#�" (probably for attempting to read it as a UTF-8 string).
  • there is a log line saying utf8_strlen - code 0x91 at position 888 is not a valid UTF-8 character

Is it possible to use Drachtio to handle this kind of SIP MESSAGEs?

Thanks!

can you also attach a pcap showing the message sipp sends over the wire?

can you also attach a pcap showing the message sipp sends over the wire?

Sure!

I've captured the message sent + 6 retransmissions of the same message.

sipp-message.zip

Let me know if there is anything else that could be helpful

Just bringing an update

I've decided to change the way drachtio-server and drachtio-srf communicate by reading the body as Buffers and not UTF-8 strings depending on the Content-Type value. Still working on this, so it's not totally clear for me what the impacts will be, but at least the communication server -> srf seems to be working fine for my use cases. I will probably be working on srf -> server on the next few days

please test to be sure that bodies containing things like emojis still work properly. I think there are some test cases already for that.

Hi there
Just an update, on the past few weeks I was able to change the way drachtio processes the body so it's handled as Buffers. It will be used on a very specific SMSC usecase and the changes were only tested for that, so I dont really think it viable for a fork or even a PR.
Will close this issue for now, thanks!