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.
| Field | Type | Description |
|---|---|---|
cmd | string | connection_kill |
operation_id | string | Any string; the server returns it in the response to match the request and the response |
uuid | string | Required. Connection identifier from connections_list, 32 hex characters |
{
"cmd": "connection_kill",
"operation_id": "abc",
"uuid": "437dc414577d4efda7121e78849bfa7a"
}
Response
| Field | Type | Description |
|---|---|---|
cmd | string | connection_kill_resp |
operation_id | string | Value from the request |
status | uint8 | 1 — the connection was found and is being closed, 2 — error |
error_code, error_text | uint8, string | Only on error, see below |
{
"cmd": "connection_kill_resp",
"operation_id": "abc",
"status": 1
}
Errors
error_code | error_text | What happened |
|---|---|---|
| 1 | Connection UUID not found | uuid 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: 1means the server found the connection and is closing it. To make sure it is closed, callconnections_listagain. - 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_listshows connections from all server instances, whileconnection_killfinds 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 theiruuid.- Connection — when else the server closes a connection.