{"record":{"id":"3b324f3facfe2234","repo":"RustPython/RustPython","slug":"ssl-shutdown-timeout-is-only-meaningful-with-ssl","errorCode":null,"errorMessage":"ssl_shutdown_timeout is only meaningful with ssl","messagePattern":"ssl_shutdown_timeout is only meaningful with ssl","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Lib/asyncio/base_events.py","lineNumber":1104,"sourceCode":"            # already-connected socket was passed or when only a port\n            # is given.  To avoid this error, you can pass\n            # server_hostname='' -- this will bypass the hostname\n            # check.  (This also means that if host is a numeric\n            # IP/IPv6 address, we will attempt to verify that exact\n            # address; this will probably fail, but it is possible to\n            # create a certificate for a specific IP address, so we\n            # don't judge it here.)\n            if not host:\n                raise ValueError('You must set server_hostname '\n                                 'when using ssl without a host')\n            server_hostname = host\n\n        if ssl_handshake_timeout is not None and not ssl:\n            raise ValueError(\n                'ssl_handshake_timeout is only meaningful with ssl')\n\n        if ssl_shutdown_timeout is not None and not ssl:\n            raise ValueError(\n                'ssl_shutdown_timeout is only meaningful with ssl')\n\n        if sock is not None:\n            _check_ssl_socket(sock)\n\n        if happy_eyeballs_delay is not None and interleave is None:\n            # If using happy eyeballs, default to interleave addresses by family\n            interleave = 1\n\n        if host is not None or port is not None:\n            if sock is not None:\n                raise ValueError(\n                    'host/port and sock can not be specified at the same time')\n\n            infos = await self._ensure_resolved(\n                (host, port), family=family,\n                type=socket.SOCK_STREAM, proto=proto, flags=flags, loop=self)\n            if not infos:","sourceCodeStart":1086,"sourceCodeEnd":1122,"githubUrl":"https://github.com/RustPython/RustPython/blob/aaeab4f754b4f40efc0c8ab39cf7c4a3c35a8cfd/Lib/asyncio/base_events.py#L1086-L1122","documentation":"ValueError from BaseEventLoop.create_connection: ssl_shutdown_timeout (seconds allowed for the TLS shutdown/close_notify phase, added in Python 3.11+) was supplied while ssl is falsy. Like ssl_handshake_timeout it only applies to the TLS lifecycle, so asyncio rejects it on plaintext connections.","triggerScenarios":"await loop.create_connection(proto, host, 80, ssl_shutdown_timeout=5.0) with ssl unset; forwarding a full kwargs dict from a TLS-aware client into a plain connection; mixing the new kwarg into calls that never enable ssl.","commonSituations":"Client libraries parameterizing every TLS option regardless of scheme; test configs that disable ssl but keep timeout settings; code written against 3.11+ kwargs run through a shared helper used for both TLS and non-TLS targets.","solutions":["Remove ssl_shutdown_timeout from non-TLS calls","Enable TLS with ssl=<SSLContext> so the shutdown timeout applies","Gate the kwarg: kwargs = {'ssl_shutdown_timeout': 5} if ctx else {}"],"exampleFix":"# before\nawait loop.create_connection(proto, 'example.com', 80,\n                                ssl_shutdown_timeout=5.0)\n\n# after\nkwargs = {'ssl_shutdown_timeout': 5.0} if ssl_ctx else {}\nawait loop.create_connection(proto, 'example.com', 80, ssl=ssl_ctx, **kwargs)","handlingStrategy":"validation","validationCode":"kwargs = {}\nif ssl_ctx is not None:\n    kwargs['ssl_shutdown_timeout'] = 5.0\n    kwargs['ssl'] = ssl_ctx\nawait loop.create_connection(proto, host, port, **kwargs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember ssl_shutdown_timeout is 3.11+; gate it by TLS being enabled","Never splat a full TLS settings dict into non-TLS calls","Key your settings objects by scheme (https vs http), not one generic blob"],"tags":["asyncio","ssl","timeout","valueerror","parameter-validation"],"backgroundTag":"ssl-configuration-error","analyzedSha":"aaeab4f754b4f40efc0c8ab39cf7c4a3c35a8cfd","analyzedAt":"2026-08-17T00:37:52.100Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}