Home AMX User Forum AMXForums Archive Threads Tips and Tricks

IP Client Reconnection

Hi all,

I have an AMX NX3200 which is sending TCP control messages to/from an Extron video switcher and DSP. At the moment, I've set it up so that within DEFINE_START, the NX3200 should establish a TCP connection with the Extron devices, and it should always remain open. Every so often, however, the TCP connection drops- I've set up a DATA_EVENT intended to re-open the TCP connection for each device, however it often doesn't seem to work and restarting the NX3200 seems to be the only way to get the connection to re-establish.

Here's the DATA_EVENT below:

DATA_EVENT[devDSP] //DSP Feedback to Diagnostics Window
{
OFFLINE:
{
IP_CLIENT_CLOSE(devDSP.PORT)
IP_CLIENT_OPEN(devDSP.PORT,devDSPIPAddress,devDSPPort,IP_TCP)
}
STRING:
{
SEND_STRING 0,"'DSP: ',dspBuffer"
CLEAR_BUFFER dspBuffer
}
}

Is there something I'm missing that prevents the NX3200 from re-establishing a connection? Do I need to add a WAIT between when the connection close and open actions occur?

Any input or suggestions are much appreciated.

Thanks,
Amina

Comments

  • The OFFLINE of a TCP connect is only done if the connection gets closed by a regular disconnection from server side, or if you do an IP_CLIENT_CLOSE(). If the connect gets lost for other reason or even doesn't get established, you get an error code (data.number) in the ONERROR section of the data_event.

    To validate errors, find attached a txt file. Rename it to AXI and use it to create messages about the error code.

    ANother issue with TCP connections is to track the connection state by a variable, kind of
    nConnection = 0 // offline; when you got the OFFLINE event
    nConnection = 1 // online; when you got the ONLINE event
    nConnection = 2 // connecting; when you do the IP_CLIENT_OPEN(), may take up to 90 seconds until you get ONLINE or ONERROR
    nConnection = 3 // disconnecting; when you do the IP_CLIENT_CLOSE()

    WHile in "connecting" state, no IP operation should be done, you have to wait until online or onerror. Otherwise you may get onerror codes (e.g. doing an IP_CLIENT_OPEN() though a connection is still tried to establish ("connecting") may result in an onerror code for "local port already in use").

    As said above, if a connection problem comes up and you get the data_event ONERROR, depending on the error code you may have to set the connection variable back to offline state manually.

Sign In or Register to comment.