【发布时间】:2016-03-09 11:12:23
【问题描述】:
我可以向特定的 url 和端口发送 udp 消息(成功),但我无法收到在 Wireshark 上可以看到的响应消息!
这是我用于 udp 连接的代码:
Byte[] sendBytes = Encoding.ASCII.GetBytes(sipMessage);
String responseData = String.Empty;
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
try
{
using (UdpClient udpClient = new UdpClient(ipaddr, 5060))
{
udpClient.Client.ReceiveTimeout = 1000;
udpClient.Send(sendBytes, sendBytes.Length);
Byte[] receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
responseData = Encoding.ASCII.GetString(receiveBytes);
}
}
catch (Exception ex)
{
responseData = ex.Message;
}
如果我不设置超时,线程会继续工作。
响应消息是:
连接尝试失败,因为连接方没有 一段时间后正确响应,或建立连接 失败,因为连接的主机没有响应
wireshark 的结果如下:
+-----+-----------+--------------+--------------+----------+--------+--------------------------------------------------------+
| No. | Time | Source | Destination | Protocol | Length | Info |
+-----+-----------+--------------+--------------+----------+--------+--------------------------------------------------------+
| 465 | 33.378167 | 192.168.1.61 | 192.168.1.63 | SIP | 289 | Request: MESSAGE sip:1001@192.168.1.61 | (text/plain) |
| 469 | 33.817460 | 192.168.1.63 | 192.168.1.61 | SIP | 254 | Status: 200 OK | |
+-----+-----------+--------------+--------------+----------+--------+--------------------------------------------------------+
附录: 192.168.1.61 是托管网页的计算机,192.168.1.63 是 wifi 检测电话
我需要向 wifi 设备发送 sip 消息(我已经实现了)
电话向 192.168.1.61:5060 发回一条 sip 消息。 SIP流程是这样的:
[随机端口] -- 消息 --> [5060]
[5060]
所以,pc 作为 udp 客户端连接到 dect 并发送消息,dect 将 200 OK sip 消息发送回 pc 的 5060 端口。我在接收 200 OK 消息时遇到问题!
新闻: 当我停止 pbx 服务器的服务时,我可以得到结果(200 OK);否则,我将无法收到任何 sip 消息...
【问题讨论】: