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

object

The request parameters for the snap_openWebSocket method.

url

string
required

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

protocols

array

The optional protocols to use for the WebSocket connection.

string

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": {}
}
}