Skip to main content

interface WebSocketOptions

Options for a WebSocket instance. This feature is non-standard.

Properties #

#protocols: string | string[]
optional

The sub-protocol(s) that the client would like to use, in order of preference.

A Headers object, an object literal, or an array of two-item arrays to set handshake's headers. This feature is non-standard.

#client: Deno.HttpClient
optional

An HttpClient instance to use when creating the WebSocket connection. This is useful when you need to connect through a proxy or customize TLS settings.

const client = Deno.createHttpClient({
  proxy: {
    transport: "unix",
    path: "/path/to/socket",
  },
});

const ws = new WebSocket("ws://localhost:8000/socket", { client });

Did you find what you needed?

Privacy policy