{"record":{"id":"21a0daaa39f3df85","repo":"vllm-project/vllm","slug":"unexpected-socket-type-socket-type","errorCode":null,"errorMessage":"Unexpected socket type: {socket_type}","messagePattern":"Unexpected socket type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vllm/distributed/kv_transfer/kv_connector/v1/moriio/moriio_common.py","lineNumber":592,"sourceCode":"                or 0\n            ),\n            remote_dp_size=kv_transfer_params.get(\"remote_dp_size\", 1),\n            remote_dp_rank=kv_transfer_params.get(\"remote_dp_rank\", 0),\n            multi_pod_hosts=_pod_hosts,\n            remote_dp_size_local=_remote_dp_size_local,\n        )\n        if write_mode:\n            self.reqs_to_save[request_id] = _req\n        else:\n            self.reqs_to_recv[request_id] = _req\n\n\n@contextlib.contextmanager\ndef zmq_ctx(socket_type: Any, addr: str) -> Iterator[zmq.Socket]:\n    \"\"\"Context manager for a ZMQ socket\"\"\"\n\n    if socket_type not in (zmq.ROUTER, zmq.REQ, zmq.DEALER):\n        raise ValueError(f\"Unexpected socket type: {socket_type}\")\n\n    ctx: zmq.Context | None = None\n    try:\n        ctx = zmq.Context()  # type: ignore[attr-defined]\n        yield make_zmq_socket(\n            ctx=ctx, path=addr, socket_type=socket_type, bind=socket_type == zmq.ROUTER\n        )\n    finally:\n        if ctx is not None:\n            ctx.destroy(linger=0)\n","sourceCodeStart":574,"sourceCodeEnd":603,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/distributed/kv_transfer/kv_connector/v1/moriio/moriio_common.py#L574-L603","documentation":"zmq_ctx is an internal context manager in moriio_common.py that only accepts zmq.ROUTER, zmq.REQ, or zmq.DEALER socket types; anything else raises ValueError before a socket is created. It guards the bind/connect logic which assumes ROUTER binds and REQ/DEALER connect.","triggerScenarios":"Calling zmq_ctx with an unsupported constant such as zmq.PUB, zmq.SUB, zmq.PUSH, or zmq.PULL. The vLLM code paths themselves only pass ROUTER and DEALER, so this is hit mainly by custom code importing the helper.","commonSituations":"Extending the MoRI-IO connector with a custom notification channel and reusing zmq_ctx with a PUB/SUB socket; copy-pasting the helper call and changing only the socket type.","solutions":["Use one of the supported types: zmq.ROUTER (server/bind side) or zmq.REQ / zmq.DEALER (client/connect side)","For genuinely different socket types, create the zmq.Context and make_zmq_socket call directly with explicit bind semantics"],"exampleFix":"// before\nwith zmq_ctx(zmq.PUB, path) as sock: ...\n\n// after\nwith zmq_ctx(zmq.ROUTER, path) as sock: ...","handlingStrategy":"type-guard","validationCode":"import zmq\n\nassert socket_type in (zmq.ROUTER, zmq.REQ, zmq.DEALER), f\"unsupported socket_type {socket_type}\"","typeGuard":"import zmq\n\ndef is_supported_moriio_socket(t) -> bool:\n    return t in (zmq.ROUTER, zmq.REQ, zmq.DEALER)","tryCatchPattern":null,"preventionTips":["Do not extend zmq_ctx with new socket types; add a dedicated helper with explicit bind semantics instead","Centralize socket-type constants next to the helper so callers cannot drift"],"tags":["zmq","internal-api","validation"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}