{"record":{"id":"146ba86e79681d1f","repo":"sgl-project/sglang","slug":"unsupported-socket-type-socket-type-146ba8","errorCode":null,"errorMessage":"Unsupported socket type: {socket_type}","messagePattern":"Unsupported socket type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/utils/network.py","lineNumber":264,"sourceCode":"        buf_size = -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.PAIR]:\n        set_send_opt()\n        set_recv_opt()\n    else:\n        raise ValueError(f\"Unsupported socket type: {socket_type}\")\n\n\ndef get_local_ip_by_nic(interface: str = None) -> Optional[str]:\n    if not (interface := interface or os.environ.get(\"SGLANG_LOCAL_IP_NIC\", None)):\n        return None\n    try:\n        import netifaces\n    except ImportError as e:\n        raise ImportError(\n            \"Environment variable SGLANG_LOCAL_IP_NIC requires package netifaces, please install it through 'pip install netifaces'\"\n        ) from e\n\n    try:\n        addresses = netifaces.ifaddresses(interface)\n        if netifaces.AF_INET in addresses:\n            for addr_info in addresses[netifaces.AF_INET]:\n                ip = addr_info.get(\"addr\")\n                if ip and ip != \"127.0.0.1\" and ip != \"0.0.0.0\":","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/network.py#L246-L282","documentation":"config_socket applies ZMQ send/recv buffer tuning per socket type; it handles PUB/SUB-ish, PUSH, PULL, DEALER/REQ/REP/PAIR patterns. Any other zmq socket type (e.g., XSUB, XPUB, STREAM, radio) hits the raise because no hwm/linger preset is defined for it.","triggerScenarios":"Calling config_socket (directly or via get_zmq_socket) with a socket type outside the supported set — e.g., zmq.XPUB for a custom broker.","commonSituations":"User code adding a custom ZMQ transport (proxy, monitor, XPUB/XSUB bus) routed through sglang's socket helper.","solutions":["Use one of the supported types (PUSH/PULL/DEALER/REQ/REP/PAIR/PUB/SUB) for custom sockets.","Create and configure the ZMQ socket manually with setsockopt instead of going through config_socket.","Contribute a branch for the new type with appropriate send/recv options."],"exampleFix":"# before\nsock = get_zmq_socket(ctx, zmq.XPUB, endpoint)\n\n# after\nsock = ctx.socket(zmq.XPUB)\nsock.set(zmq.SNDHWM, 1000)\nsock.bind(endpoint)","handlingStrategy":"validation","validationCode":"import zmq\nSUPPORTED = {zmq.PUSH, zmq.PULL, zmq.PUB, zmq.SUB, zmq.DEALER, zmq.REQ, zmq.REP, zmq.PAIR}\nassert socket_type in SUPPORTED, f\"configure {socket_type} manually\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["For exotic socket types, configure setsockopt manually instead of config_socket."],"tags":["zmq","network","socket"],"backgroundTag":"unsupported-socket-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}