{"record":{"id":"a9205b42f60898f4","repo":"aio-libs/aiohttp","slug":"extension-for-deflate-not-supported-ext-group-1","errorCode":null,"errorMessage":"Extension for deflate not supported{ext.group(1)}","messagePattern":"Extension for deflate not supported(.+?)","errorType":"exception","errorClass":"WSHandshakeError","httpStatus":null,"severity":"error","filePath":"aiohttp/_websocket/helpers.py","lineNumber":124,"sourceCode":"                    notakeover = True\n                # Ignore regex group 5 & 6 for client_max_window_bits\n                break\n            else:\n                if match.group(6):\n                    compress = int(match.group(6))\n                    # Group5 must match if group6 matches\n                    # Compress wbit 8 does not support in zlib\n                    # If compress level not support,\n                    # FAIL the parse progress\n                    if compress > 15 or compress < 9:\n                        raise WSHandshakeError(\"Invalid window size\")\n                if match.group(2):\n                    notakeover = True\n                # Ignore regex group 5 & 6 for client_max_window_bits\n                break\n        # Return Fail if client side and not match\n        elif not isserver:\n            raise WSHandshakeError(\"Extension for deflate not supported\" + ext.group(1))\n\n    return compress, notakeover\n\n\ndef ws_ext_gen(\n    compress: int = 15, isserver: bool = False, server_notakeover: bool = False\n) -> str:\n    # client_notakeover=False not used for server\n    # compress wbit 8 does not support in zlib\n    if compress < 9 or compress > 15:\n        raise ValueError(\n            \"Compress wbits must between 9 and 15, zlib does not support wbits=8\"\n        )\n    enabledext = [\"permessage-deflate\"]\n    if not isserver:\n        enabledext.append(\"client_max_window_bits\")\n\n    if compress < 15:","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/aio-libs/aiohttp/blob/d041d4d0fd48c3f0832084d33be16cf1c4835f85/aiohttp/_websocket/helpers.py#L106-L142","documentation":"The client found a `permessage-deflate` token in the server's `Sec-WebSocket-Extensions` header, but its parameter list did not match the expected grammar (`_WS_EXT_RE` in `helpers.py`). Because the client offered compression and the server's response is malformed or carries unsupported parameters, the handshake fails with `WSHandshakeError` (surfaced as `WSServerHandshakeError`).","triggerScenarios":"Client requests compression; server replies with `Sec-WebSocket-Extensions: permessage-deflate; <params>` where `<params>` fails `_WS_EXT_RE` — e.g. unknown parameters, bad separators, or an unexpected parameter form. `ws_ext_parse(..., isserver=False)` raises at `helpers.py:124`.","commonSituations":"A non-standard server/proxy adds unsupported deflate parameters; a CDN rewrites the extension header; the server emits parameters the regex doesn't accept (only `server_no_context_takeover`, `client_no_context_takeover`, `server_max_window_bits`, `client_max_window_bits` are recognized).","solutions":["Retry the connection without compression: `ws_connect(url, compress=0)`.","If you control the server, send only the four recognized parameters with correct `; `-separated syntax.","Wrap `ws_connect` in try/except `WSServerHandshakeError` and degrade to uncompressed WS."],"exampleFix":"# before\nws = await session.ws_connect(url, compress=15)  # server params failed to parse -> error\n# after\ntry:\n    ws = await session.ws_connect(url, compress=15)\nexcept aiohttp.WSServerHandshakeError:\n    ws = await session.ws_connect(url, compress=0)","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    ws = await session.ws_connect(url, compress=15)\nexcept aiohttp.WSServerHandshakeError:\n    ws = await session.ws_connect(url, compress=0)","preventionTips":["Implement a compressed->uncompressed fallback when negotiating with unknown servers.","Validate server extension headers against RFC 7692 during integration testing."],"tags":["websocket","handshake","compression","deflate","extension"],"backgroundTag":null,"analyzedSha":"d041d4d0fd48c3f0832084d33be16cf1c4835f85","analyzedAt":"2026-08-11T20:44:15.550Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}