[OpenSIPS-Users] t_uac_dlg command through mi_datagram socket gives 400 bad headers

Husnain Taseer husnain.taseer at gmail.com
Tue Mar 21 08:28:02 EDT 2017


I have successfully sent MESSAGE using mi_json module. Below information
might be helpful for other opensips users as well.

​I have mi_json param string:

sip:​212897645@​\r\nContent-Type: text/plain;
charset=UTF-8\r\n​,,Hi How are you ?

​We have to URL encode this string before sending it to mi_json. Use online
URL encoder I have used [https://www.urlencoder.org/]. When you will encode
the above string /r and /n will be considered two characters each but we
need to encode them as Carriage Return (%0D) and Line Feed (%0A). In simple
words URL encode of /r should be %0D not %5Cr and for /n it should be %0A
not %5Cn For That modify the above string as:

MESSAGE,sip:​212897645@​,.,.,From: sip:​212897554@​
To: sip:​212897645@​
Content-Type: text/plain; charset=UTF-8
​,Hi How are you ?

Now encode the above string it will become:


Now Pass the above string as a parameter of t_uac_dlg command in curl:

curl "

The Message will be successfully sent to the the destination number. I will
work on mi_datagram and will post the example of sending MESSAGE from
datagram socket as well.

*Husnain Taseer - **VoIP Development professional*
*Cell : +973 3353 8026*

On Mon, Mar 6, 2017 at 11:17 AM, Husnain Taseer <husnain.taseer at gmail.com>

> Hi Folks!
> I am trying to generate a MESSAGE packet using t_uac_dlg command from a
> management script written in Python. I have tried different combination of
> argument string but either getting parsing error or 400 bad headers error.
> The string which I am sending to mi_datagram socket in my Python script is:
> *message = ''':t_uac_dlg:\nMESSAGE\n​​sip:​​212897645 at
> <nsip%3A212897645 at>\n.\n.\n"From:
> <sip:​​212897554@​​ <sip%3A212897554 at>>\\r\\nTo:
> <sip:212897645 at
> <sip%3A212897645 at>>\\r\\np-identifier:
> Local_Socket_V1.0\\r\\nContent-Type: text/plain\\r\\n"\n"Hi This is a Test
> Message"\n'''*
> When I print the above string it gives me the value given below:
> :t_uac_dlg:
> sip:212897645 at
> .
> .
> "From: <sip:212897554 at>\r\nTo: <sip:212897645 at>\r\np-identifier:
> Local_Socket_V1.0\r\nContent-Type: text/plain\r\n"
> "Hi This is a test"
> When I send this string to mi_datagram socket it gives me *400 Bad
> headers *Please guide where I am doing wrong.
> Regards,
> *Husnain Taseer*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20170321/215688a1/attachment.html>

More information about the Users mailing list