Skip to main content
  • Snap

snap_openWebSocket

Description

Open a WebSocket connection to the specified URL with optional protocols.

Note: This method is only available to snaps that have the endowment:network-access permission.

Parameters

url

stringrequired

The wss:// URL of the WebSocket connection to open.

protocols

string[] | null

The optional protocols to use for the WebSocket connection.

Returns

string

The ID of the opened WebSocket connection, which can be used to reference the connection in subsequent calls to snap_sendWebSocketMessage and snap_closeWebSocket.

Example

{
"initialPermissions": {
"endowment:network-access": {}
}
}