Skip to main content

Disconnect client

Closes a WebSocket connection by its uuid. Use it when a hung or forgotten client holds a connection: the client counts toward the application's connection limit or, if it is subscribed, takes part of the data. Get the uuid from connections_list.

Request and response: connection_kill → connection_kill_resp.
Access: a token of any access level.

Request​

Fields not marked as required may be omitted.

FieldTypeDescription
cmdstringconnection_kill
operation_idstringAny string; the server returns it in the response to match the request and the response
uuidstringRequired. Connection identifier from connections_list, 32 hex characters
{
"cmd": "connection_kill",
"operation_id": "abc",
"uuid": "437dc414577d4efda7121e78849bfa7a"
}

Response​

FieldTypeDescription
cmdstringconnection_kill_resp
operation_idstringValue from the request
statusuint81 — the connection was found and is being closed, 2 — error
error_code, error_textuint8, stringOnly on error, see below
{
"cmd": "connection_kill_resp",
"operation_id": "abc",
"status": 1
}

Errors​

error_codeerror_textWhat happened
1Connection UUID not founduuid is missing, the connection with this uuid no longer exists, or it is served by another server instance

Good to know​

  • The response arrives before the connection is closed. status: 1 means the server found the connection and is closing it. To make sure it is closed, call connections_list again.
  • The disconnected client gets no message. The server drops its connection without a Close frame; the client sees a dropped connection, e.g. code 1006 in a browser WebSocket. Its data subscription is removed.
  • The client can connect again. The command does not block the client: if it is set up to reconnect, it will reconnect.
  • You can close your own connection too. If you pass your own uuid, the server sends the response and closes the current connection right away.
  • Only connections of the same server instance. connections_list shows connections from all server instances, while connection_kill finds only connections of the instance you are connected to. For the others the response is error 1.

See also​

  • connections_list — the list of the application's connections and their uuid.
  • Connection — when else the server closes a connection.