我可以建立到PABX的TCP连接。它提示,我可以登录,并接收一些电话记录。但不久之后,PABX就无缘无故地放弃了连接,我无法理解。我和Wireshark联系过了。
在this related question,CharlesO说
您只需编写一个TCP侦听器来接受来自PBX的连接,并解析传入呼叫详细记录(CDR)。 已与Avaya、松下和其他PABX产品成功地完成了这一任务。
这是否意味着问题就在于设计是“不要打电话给我们,我们会打电话给你”?
发布于 2014-08-18 15:04:03
嗅探PABX与商业呼叫记录器之间的通信量,会发现PABX没有什么好的理由经常丢弃连接,任何希望记录呼叫数据的应用程序都必须监视连接的状态。
由于在写入失败之前,TcpClient不会检测状态的变化,而且这完全是侦听套接字,因此需要更直接的方法来处理连接状态:
public static class Extensions
{
/// <summary>
/// Obtain the current state of the socket underpinning a TcpClient.
/// Unlike TcpClient.Connected this is reliable and does not require
/// capture of an exception resulting from a failed socket write.
/// </summary>
/// <param name="tcpClient">TcpClient instance</param>
/// <returns>Current state of the TcpClient.Client socket</returns>
public static TcpState GetState(this TcpClient tcpClient)
{
var foo = IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections()
.SingleOrDefault(x => x.LocalEndPoint.Equals(tcpClient.Client.LocalEndPoint));
return foo != null ? foo.State : TcpState.Unknown;
}
}处理冗余的呼叫日志也是必要的,因为在重新建立连接时经常会重复这些日志。
https://stackoverflow.com/questions/25255507
复制相似问题