Asterisk 传入消息给出:415 unsupported media type

Asterisk incoming message gives: 415 unsupported media type

我和我的项目组正在尝试设置带有星号的 PBX。我们设法让它只与 SIP 呼叫一起工作,而且效果很好。 但是一旦我们想尝试向它添加 XML 消息,Asterisk 就无法识别它并给出“415 Unsupported Media Type”。好像这个电话甚至没有打通就立即被拒绝了。

我们试图找到处理此问题的代码段,但没有找到任何东西。

发送到 Asterisk 的 SIP 消息如下所示:

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

我们的问题is/are: 我们可以在代码或配置文件的哪个位置找到星号决定是否支持 "media type" 的位置?

或者

有人知道如何添加 Asterisk(还)不支持的媒体类型吗?

消息接受的内容类型似乎是硬编码的,因此您无法在配置文件中执行此操作。如果您查看 channels\chan_sip.c 中的函数 receive_message(),您将看到以下行:

    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( ) 功能以满足您的需要。

您可能只使用 "text/plain" 作为 Content-Type 并通过自动检测在您的应用中处理 scaip+xml(例如,如果消息以 开头,那么您可以知道它是 scaip xml).