Nabil
09/04/2023, 2:29 PMSecWebSocketExtensions
header (i.e Sec-WebSocket-Extensions
) when using io.ktor:ktor-client-okhttp:2.1.2
(even though I didn’t specify any extension in the configuration (see configuration below) this Header should be optional according to the spec. this is causing an issue for my client since the value set is permessage-deflate
which causes the server to compress the frames. Is there a configuration to disable this behaviour or is it a bug (I’ve noticed a user reported similar issue with CIO)
Note: you can easily reproduce it using the official :tutorial-websockets-client
(just switch the client to OkHttp instead of CIO)
My client conf:
client.webSocket( method = HttpMethod.Get,
host = address,
port = port,
path = path,
request = {
header(HttpHeaders.SecWebSocketProtocol, supportedProtocols)
}
)
WireShark Request and Response
Transmission Control Protocol, Src Port: 53272, Dst Port: 9090, Seq: 1, Ack: 1, Len: 1385
Hypertext Transfer Protocol
[truncated]GET /api/****
Sec-WebSocket-Protocol: ***\r\n
Accept-Charset: UTF-8\r\n
Accept: */*\r\n
User-Agent: Ktor client\r\n
Upgrade: websocket\r\n
Connection: Upgrade\r\n
Sec-WebSocket-Key: ***\r\n
Sec-WebSocket-Version: 13\r\n
Sec-WebSocket-Extensions: permessage-deflate\r\n. <------------------------ This header is set by Ktor automatically
Host: localhost:9090\r\n
Accept-Encoding: gzip\r\n
Transmission Control Protocol, Src Port: 9090, Dst Port: 53272, Seq: 1, Ack: 1386, Len: 487
Hypertext Transfer Protocol
HTTP/1.1 101 Switching Protocols\r\n
Cache-Control: no-cache, no-store, must-revalidate\r\n
Connection: Upgrade\r\n
Sec-Websocket-Accept: ***\r\n
Sec-Websocket-Extensions: permessage-deflate; client_no_context_takeover; server_no_context_takeover\r\n
Sec-Websocket-Protocol: ***\r\n
Strict-Transport-Security: max-age=31536000; includeSubdomains;\r\n
Upgrade: websocket\r\n
Vary: Origin\r\n
X-Appservices-Request-Id: 64f2ad66ff71568d3176fce6\r\n
UsingAleksei Tirman [JB]
09/04/2023, 3:55 PMNabil
09/04/2023, 4:07 PMSec-WebSocket-Protocol
header with supported clients protocol and I need obviously to read back the Sec-WebSocket-Protocol
sent back from the server to know which protocol it selected.Nabil
09/05/2023, 11:23 AM