Why does AMPS disconnect a client with a 'name in use' error?
When a transaction log is configured, AMPS needs to be able to tell the difference between connections to be able to reliably persist and replay the message stream. AMPS uses the client name as a unique application identifier to be able to tell when a connection is a connection from a different client as compared to a new connection from the same client.
The contract between AMPS and the application is that the application must provide a client name that will uniquely and consistently identify a particular instance of the client application. The same instance of the same application should use the client name each time that instance connects, and should not use the same client name as another instance.
In this case, when AMPS receives a new connection with the same client name as an existing connection, with the same authenticated ID, AMPS disconnects the existing connection.
You may wonder why AMPS does this -- why not just use the existing connection?
AMPS does this to help applications get reconnected quickly in the event of a network outage or client restart. Clients typically use TCP/IP and may be connecting through any combination of WAN, WiFi, VPN, traversing multiple firewalls, and so on. It can be a matter of minutes before the OS notifies AMPS that a connection is closed (with TCP KeepAlive enabled -- without KeepAlive enabled, it could take forever). If AMPS were to deny a new connection until the previous connection closed, the application could be offline for minutes (or even longer).
To get applications back online quickly, AMPS makes the assumption that a new connection with the same client name (that authenticates as the same user) is intended to replace the existing connection. AMPS disconnects the existing connection in favor of the new connection. The disconnect happens immediately: AMPS does not pause the new connection or notify the old the connection.
Last updated