A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close below:

WebSocket: close() method - Web APIs

WebSocket: close() method

Baseline Widely available

Note: This feature is available in Web Workers.

The WebSocket.close() method closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.

Note: The process of closing the connection begins with a closing handshake, and the close() method does not discard previously-sent messages before starting that closing handshake; even if the user agent is still busy sending those messages, the handshake will only start after the messages are sent.

Syntax
close()
close(code)
close(code, reason)
Parameters
code Optional

An integer WebSocket connection close code value indicating a reason for closure:

reason Optional

A string providing a custom WebSocket connection close reason (a concise human-readable prose explanation for the closure). The value must be no longer than 123 bytes (encoded in UTF-8).

Note: Because UTF-8 uses two to four bytes to encode any non-ASCII characters, a 123-character reason value containing non-ASCII characters would exceed the 123-byte limit.

If you specify a reason value, you should also specify a code value.

Return value

None (undefined).

Exceptions
InvalidAccessError DOMException

Thrown if code is neither an integer equal to 1000 nor an integer in the range 3000 – 4999.

SyntaxError DOMException

Thrown if the UTF-8-encoded reason value is longer than 123 bytes.

Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4