{"record":{"id":"c3264b2df5d09f38","repo":"sgl-project/sglang","slug":"unsupported-socket-type-socket-type","errorCode":null,"errorMessage":"Unsupported socket type: {socket_type}","messagePattern":"Unsupported socket type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/utils/common.py","lineNumber":258,"sourceCode":"        socket.setsockopt(zmq.IPV6, 1)\n\n    def set_send_opt():\n        socket.setsockopt(zmq.SNDHWM, 0)\n        socket.setsockopt(zmq.SNDBUF, buf_size)\n\n    def set_recv_opt():\n        socket.setsockopt(zmq.RCVHWM, 0)\n        socket.setsockopt(zmq.RCVBUF, buf_size)\n\n    if socket_type == zmq.PUSH:\n        set_send_opt()\n    elif socket_type == zmq.PULL:\n        set_recv_opt()\n    elif socket_type in [zmq.DEALER, zmq.REQ, zmq.REP, zmq.ROUTER]:\n        set_send_opt()\n        set_recv_opt()\n    else:\n        raise ValueError(f\"Unsupported socket type: {socket_type}\")\n\n    if bind:\n        # Parse port from endpoint for retry logic\n        import re\n\n        port_match = re.search(r\":(\\d+)$\", endpoint)\n\n        if port_match and max_bind_retries > 1:\n            import time as _time\n\n            original_port = int(port_match.group(1))\n            last_exception = None\n\n            for attempt in range(max_bind_retries):\n                try:\n                    current_endpoint = endpoint\n                    if attempt > 0 and not same_port:\n                        # Try next port (increment by 42 to match settle_port logic)","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/utils/common.py#L240-L276","documentation":"Thrown by get_zmq_socket when the requested zmq socket type is not one of the handled kinds (PUSH/PUB via set_send_opt, PULL/SUB, or DEALER/REQ/REP/ROUTER which set both). Any other socket type constant is rejected.","triggerScenarios":"Calling get_zmq_socket with e.g. zmq.PAIR, zmq.XPUB, zmq.XSUB, or zmq.STREAM — types outside the supported set.","commonSituations":"Adding a new ZMQ pattern (PAIR for 1:1 channels, XPUB/XSUB for fan-out) to the runtime without extending get_zmq_socket's branch list.","solutions":["Use one of the supported types: PUSH, PUB, PULL, SUB, DEALER, REQ, REP, ROUTER","If you need another type (e.g. PAIR), extend get_zmq_socket in common.py with an appropriate branch (set_send_opt/set_recv_opt or neither)","Check for a typo — passing an uninitialized/incorrect zmq constant can land in the else branch"],"exampleFix":"# before\nsock = get_zmq_socket(ctx, zmq.PAIR, \"tcp://127.0.0.1:5555\", bind=True)\n# after\nsock = get_zmq_socket(ctx, zmq.DEALER, \"tcp://127.0.0.1:5555\", bind=True)","handlingStrategy":"type-guard","validationCode":"import zmq\nSUPPORTED = {zmq.PUSH, zmq.PUB, zmq.PULL, zmq.SUB, zmq.DEALER, zmq.REQ, zmq.REP, zmq.ROUTER}\nassert socket_type in SUPPORTED, f\"unsupported zmq type {socket_type}\"","typeGuard":"def is_supported_zmq_type(t: int) -> bool:\n    import zmq\n    return t in (zmq.PUSH, zmq.PUB, zmq.PULL, zmq.SUB, zmq.DEALER, zmq.REQ, zmq.REP, zmq.ROUTER)","tryCatchPattern":"try:\n    sock = get_zmq_socket(ctx, stype, ep, bind=True)\nexcept ValueError as e:\n    if \"Unsupported socket type\" in str(e):\n        stype = zmq.DEALER  # fallback to a supported pattern\n        sock = get_zmq_socket(ctx, stype, ep, bind=True)\n    else:\n        raise","preventionTips":["Centralize socket-type choice behind constants/enums in your code","Add PAIR/XPUB support in get_zmq_socket if your topology needs it"],"tags":["zmq","socket","validation"],"backgroundTag":"unsupported-socket-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}