Talking to a KX-NCP1000 PABX

219 views Asked by At

I can establish a TCP connection to the PABX. It prompts and I can log in, and receive a few call records. But after not very long the PABX drops the connection for no reason I can fathom. It's definitely getting ACKs, I checked with Wireshark.

In this related question CharlesO says

You simply write a TCP Listener to accept connection from the PBX and parse the incoming Call Detail Records (CDR).

Have done this successfully with Avaya, Panasonic and other PABX Products

Does this mean the problem is simply that the design is "don't call us, we'll call you" ?

1

There are 1 answers

0
Peter Wone On BEST ANSWER

Sniffing the traffic between the PABX and a commercial call logger reveals that the PABX frequently drops the connection for no good reason and any app wishing to log call data must monitor the state of the connection.

Since TcpClient won't detect a change of state until a write fails and this is strictly a listening socket, a more direct approach to connection status is required:

  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;
    }
  }

It is also necessary to handle redundant call logs since these are often repeated when the connection is re-established.