{"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/d9aaf697c2cd4783ca5749a971965c689f3ec24f/aiohttp/_websocket/helpers.py#L106-L142","documentation":"Raised as WSHandshakeError in ws_ext_parse() at _websocket/helpers.py:124 on the CLIENT side (isserver=False) when the server's permessage-deflate extension string contains parameters that do not match the _WS_EXT_RE grammar (server_no_context_takeover / client_no_context_takeover / server_max_window_bits / client_max_window_bits). The offending tail (ext.group(1)) is appended so you can see exactly which unsupported parameter was sent. In client.py:1151 it is re-raised as aiohttp.WSServerHandshakeError.","triggerScenarios":"Awaiting `session.ws_connect(url, compress>0)` against a server whose Sec-Websocket-Extensions header carries an unknown/ malformed permessage-deflate parameter, e.g. `permessage-deflate; foo=bar` or an extension name other than permessage-deflate that the client did not negotiate.","commonSituations":"Intermediary (proxy/load balancer) injecting a non-standard deflate parameter; a server implementing a draft or proprietary deflate extension; server sending an extension the client never offered.","solutions":["Disable client-side compression: `ws_connect(url, compress=0)` so the extension header is never parsed.","Correct the server to send only RFC 7692 permessage-deflate parameters.","Catch aiohttp.WSServerHandshakeError and retry without compression."],"exampleFix":"// before\nws = await session.ws_connect(url, compress=15)\n\n# after\nws = await session.ws_connect(url, compress=0)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    ws = await session.ws_connect(url, compress=15)\nexcept aiohttp.WSServerHandshakeError as exc:\n    if 'Extension for deflate not supported' in (exc.message or ''):\n        ws = await session.ws_connect(url, compress=0)\n    else:\n        raise","preventionTips":["Use compress=0 if the server/proxy is known to send non-standard deflate parameters.","Ensure the server only returns permessage-deflate parameters the client actually offered.","Log WSServerHandshakeError.message so unsupported-extension issues are diagnosable."],"tags":["websocket","handshake","compression","deflate","permessage-deflate"],"analyzedSha":"d9aaf697c2cd4783ca5749a971965c689f3ec24f","analyzedAt":"2026-08-06T21:30:48.638Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}