{"record":{"id":"c0ae79ab949a16c3","repo":"ytdl-org/youtube-dl","slug":"0-bytes-missing","errorCode":null,"errorMessage":"{0} bytes missing","messagePattern":"(.+?) bytes missing","errorType":"exception","errorClass":"EOFError","httpStatus":null,"severity":"error","filePath":"youtube_dl/socks.py","lineNumber":126,"sourceCode":"    'type', 'host', 'port', 'username', 'password', 'remote_dns'))\n\n\nclass sockssocket(socket.socket):\n    def __init__(self, *args, **kwargs):\n        self._proxy = None\n        super(sockssocket, self).__init__(*args, **kwargs)\n\n    def setproxy(self, proxytype, addr, port, rdns=True, username=None, password=None):\n        assert proxytype in (ProxyType.SOCKS4, ProxyType.SOCKS4A, ProxyType.SOCKS5)\n\n        self._proxy = Proxy(proxytype, addr, port, username, password, rdns)\n\n    def recvall(self, cnt):\n        data = b''\n        while len(data) < cnt:\n            cur = self.recv(cnt - len(data))\n            if not cur:\n                raise EOFError('{0} bytes missing'.format(cnt - len(data)))\n            data += cur\n        return data\n\n    def _recv_bytes(self, cnt):\n        data = self.recvall(cnt)\n        return compat_struct_unpack('!{0}B'.format(cnt), data)\n\n    @staticmethod\n    def _len_and_data(data):\n        return compat_struct_pack('!B', len(data)) + data\n\n    def _check_response_version(self, expected_version, got_version):\n        if got_version != expected_version:\n            self.close()\n            raise InvalidVersionError(expected_version, got_version)\n\n    def _resolve_address(self, destaddr, default, use_remote_dns):\n        try:","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/socks.py#L108-L144","documentation":"Raised (EOFError) by sockssocket.recvall when the socket closes before the expected number of bytes for the current SOCKS handshake step have arrived. The message states how many bytes of the current read are still missing. It is a Python EOFError, not an ExtractorError, so it surfaces as an unexpected network failure during proxy negotiation.","triggerScenarios":"Using --proxy socks4:// or socks5:// where the proxy (or an intermediary) closes the connection mid-handshake: wrong port serving a non-SOCKS protocol that resets, proxy process crashing, firewall/LB dropping the connection, or the server rejecting the client immediately.","commonSituations":"Pointing --proxy at an HTTP proxy port with a socks5:// scheme; overloaded or flaky public SOCKS proxies; NAT/firewall idle-kill during slow negotiations; proxy bound to a different address family.","solutions":["Confirm the proxy really speaks SOCKS on that port: 'curl -x socks5h://host:port https://example.com'","Check the scheme matches the proxy type (socks5:// vs socks4:// vs http://) in --proxy","Try the proxy from another network/machine to rule out firewall resets","Use a reliable proxy or retry — transient drops on free SOCKS servers are common"],"exampleFix":"# before\nyoutube-dl --proxy 'socks5://127.0.0.1:8080' URL   # 8080 is an HTTP proxy\n# after\nyoutube-dl --proxy 'socks5://127.0.0.1:1080' URL   # actual SOCKS port","handlingStrategy":"retry","validationCode":"import socket\n\ndef socks_port_alive(host, port, timeout=3):\n    try:\n        s = socket.create_connection((host, port), timeout)\n        s.close()\n        return True\n    except OSError:\n        return False\n\nassert socks_port_alive(proxy_host, proxy_port), 'proxy unreachable before we start'","typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try:\n        ydl.download([url]); break\n    except EOFError as e:\n        if 'bytes missing' in str(e):\n            continue  # transient drop during SOCKS handshake — retry\n        raise","preventionTips":["Validate the proxy with 'curl -x socks5h://host:port' before pointing youtube-dl at it","Match the --proxy scheme to the real protocol; an HTTP port will reset SOCKS handshakes","Prefer stable, authenticated proxies over free lists for unattended jobs"],"tags":["socks","proxy","network","connection-closed"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}