WebSocket

The TLS-Client supports WebSocket connections with the same TLS fingerprinting as regular HTTP requests. This ensures consistent fingerprinting across both HTTP and WebSocket connections.

Important: WebSocket connections require HTTP/1.1. You must use WithForceHttp1() when creating the HTTP client.

Usage (Go)

// Create HTTP client with ForceHttp1 (required for WebSocket!)
client, err := tls_client.NewHttpClient(tls_client.NewNoopLogger(),
    tls_client.WithClientProfile(profiles.Chrome_133),
    tls_client.WithForceHttp1(),
)

// Create WebSocket with optional header ordering
headers := http.Header{
    "User-Agent": {"MyBot/1.0"},
    http.HeaderOrderKey: {"host", "upgrade", "connection", "user-agent"},
}

ws, err := tls_client.NewWebsocket(nil,
    tls_client.WithUrl("wss://example.com/ws"),
    tls_client.WithTlsClient(client),
    tls_client.WithHeaders(headers),
)

conn, err := ws.Connect(context.Background())
defer conn.Close()

WebSocket Options

  • WithUrl

  • WithTlsClient

  • WithHeaders

  • WithReadBufferSize

  • WithWriteBufferSize

  • WithHandshakeTimeoutMilliseconds

  • WithCookiejar

Last updated