Re: [OpenSIPS-Users] t_uac_dlg command through mi_datagram socket gives 400 bad headers
Hi, 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: MESSAGE,sip:212897645@192.168.1.20,.,.,From: sip:212897554@192.168.1.20\r\nTo: sip:212897645@192.168.1.20\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@192.168.1.20,.,.,From: sip:212897554@192.168.1.20 To: sip:212897645@192.168.1.20 Content-Type: text/plain; charset=UTF-8 ,Hi How are you ? Now encode the above string it will become: MESSAGE%2Csip%3A%E2%80%8B212897645%40%E2%80%8B192.168.1.20%2C.%2C.%2CFrom%3A+sip%3A%E2%80%8B212897554%40%E2%80%8B192.168.1.20%0D%0ATo%3A+sip%3A%E2%80%8B212897645%40%E2%80%8B192.168.1.20%0D%0AContent-Type%3A+text%2Fplain%3B+charset%3DUTF-8%0D%0A%E2%80%8B%2CHi+How+are+you+%3F%0D%0A Now Pass the above string as a parameter of t_uac_dlg command in curl: curl "http://127.0.0.1:8080/json/t_uac_dlg?params= MESSAGE%2Csip%3A%E2%80%8B212897645%40%E2%80%8B192.168.1.20%2C.%2C.%2CFrom%3A+sip%3A%E2%80%8B212897554%40%E2%80%8B192.168.1.20%0D%0ATo%3A+sip%3A%E2%80%8B212897645%40%E2%80%8B192.168.1.20%0D%0AContent-Type%3A+text%2Fplain%3B+charset%3DUTF-8%0D%0A%E2%80%8B%2CHi+How+are+you+%3F%0D%0A " 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. Regards, *Husnain Taseer - **VoIP Development professional* *Cell : +973 3353 8026* On Mon, Mar 6, 2017 at 11:17 AM, Husnain Taseer wrote: > 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\nsip:212897645@192.168.1.20 > \n.\n.\n"From: > >\\r\\nTo: > >\\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: > MESSAGE > sip:212897645@192.168.1.20 > . > . > "From: \r\nTo: > \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* > ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] t_uac_dlg command through mi_datagram socket gives 400 bad headers
Hi, I have got hint from ctd.sh script and modified my string as per the string being used in that script for INVITE. After modification I am getting error Content-Type missing. The string is now as follows: message=""":t_uac_dlg: MESSAGE sip:212897645@192.168.1.20 . . "From: \\r\\nTo: \\r\\nContent-Type: text/plain\\r\\np-identifier: Local_Socket_V1.0\\r\\n " "Hi " """ The debug logs for mi_datagram module are as follows: Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:identify_command: the command starts here: t_uac_dlg:#012MESSAGE#012sip:212897645@192.168.1.20#012.#012.#012" From: \r\nTo: \r\nContent-Type: text/plain\r\np-identifier: Local_Socket_V1.0\r\n#012"#012"Hi#012" Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:identify_command: the command is t_uac_dlg Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:identify_command: dtgram->len is 195 Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:identify_command: dtgram->len is 183 Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_server: we have a valid command Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_server: after identifing the command, the received datagram is MESSAGE#012sip:212897645@192.168.1.20#012.#012.#012"From: \r\nTo: \r\nContent-Type: text/plain\r\np-identifier: Local_Socket_V1.0\r\n#012"#012"Hi#012" Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_tree: adding node <> ; val \r\nTo: \r\nContent-Type: text/plain\r\np-identifier: Local_Socket_V1.0\r\n#012> Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_tree: the remaining datagram has 7 bytes Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_node: the remaining datagram to be parsed is #012"Hi#012"#012 and 7 in length Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_node: we have a quoted value, "Hi#012" Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_node: " found p is " Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_node: we have reached the end of attr value, p is " Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_node: attr value found Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_node: line ended properly case1 Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_node: 1 data->len is 7 Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_node: 2 data->len is 1 Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_tree: adding node <> ; val Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_tree: the remaining datagram has 1 bytes Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_parse_node: the remaining datagram to be parsed is #012 and 1 in length Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_server: done parsing the mi tree Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_server: command process (t_uac_dlg)succeded Mar 6 16:01:53 VoIPDevSys opensips[26600]: DBG:mi_datagram:mi_datagram_server: the response: 400 Content-Type missin#012 has been sent in 24 octets From above logs I can see that Content-Type is present in the request but still I am getting this error and opensips is sending back 400 Content-Type missin#012. The above logs are not complete if you need complete logs I can give you on pastebin. Regards, *Husnain Taseer* ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
[OpenSIPS-Users] t_uac_dlg command through mi_datagram socket gives 400 bad headers
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\nsip:212897645@192.168.1.20 \n.\n.\n"From: >\\r\\nTo: >\\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: MESSAGE sip:212897645@192.168.1.20 . . "From: \r\nTo: \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* ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users