星号传入消息给出:415 不受支持的媒体类型 [英] Asterisk incoming message gives: 415 unsupported media type
问题描述
我和我的项目组正在尝试设置带有星号的 PBX.我们已经设法让它只与 SIP 呼叫一起工作,而且效果很好.但是一旦我们想尝试向其中添加 XML 消息,Asterisk 就无法识别它并给出415 Unsupported Media Type".似乎电话甚至没有通过它就被立即拒绝了.
Me and my project group are trying to set up a PBX with asterisk. We've managed to let it work with just SIP calls and that works perfect. But once we want to try add an XML message to it Asterisk doesn't recognize it and gives "415 Unsupported Media Type". It seems like the call isn't even making it through it is getting rejected immediately.
我们试图找到处理这个的代码段,但没有找到任何东西.
We have tried to find the piece of code where this gets handled but didn't found anything.
发送到 Asterisk 的 SIP 消息如下所示:
The SIP message that is send to Asterisk looks like this:
Request-Line: MESSAGE sip:701@xxx.xxx.xxx.109 SIP/2.0
Method: MESSAGE
Request-URI: sip:701@xxx.xxx.xxx.109
Via: SIP/2.0/UDP xxx.xxx.xxx.111:5060;branch=z9hG4bK-3f138a53
To: <sip:701@xxx.xxx.xxx.109>
From: <sip:702@xxx.xxx.xxx.111>;tag=7a82b127
Call-ID: 54634d4f2e@xxx.xxx.xxx.111
CSeq: 104 MESSAGE
Max-Forwards: 70
User-Agent: CareIP 7813409 v1.2.4.0
Content-Type: application/scaip+xml
Content-Length: 91
Message Body
<mrq><ref>765745670002</ref<mty>ME</mty><cid>266786</cid><dty>0005</dty><stc>0010</stc></mrq
我们的问题是:我们可以在代码或配置文件的何处找到星号决定是否支持媒体类型"的位置?
Our question(s) is/are: Where in the code or config files can we find where asterisk decides whether this is "media type" supported or not?
或
有人知道如何添加 Asterisk 不支持的媒体类型吗?
Does someone know how to add a media type that is not supported (yet) by Asterisk?
推荐答案
似乎接受的消息 Content-Type 是硬编码的,因此您将无法在配置文件中执行此操作.如果你查看channelschan_sip.c中的receive_message()函数,你会看到以下几行:
It looks like the accepted Content-Type for a Message is hard-coded, so you won't be able to do this in a config file. If you look at the function receive_message() in channelschan_sip.c, you will see the following lines:
if (strncmp(content_type, "text/plain", strlen("text/plain"))) { /* No text/plain attachment */
transmit_response(p, "415 Unsupported Media Type", req); /* Good enough, or? */
如果修改 strncmp() 也允许application/scaip+xml"并重新编译,它将不再响应 415 Unsupported Media Type 错误,您可以修改 receive_message() 函数的其余部分以适应您的需求.
If you modify the strncmp() to also allow "application/scaip+xml" and recompile, it will no longer respond with the 415 Unsupported Media Type error, and you can modify the rest of the receive_message() function to suit your needs.
这篇关于星号传入消息给出:415 不受支持的媒体类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!