vllm-project/vllm · error · ValueError

Unexpected socket type: {socket_type}

Error message

Unexpected socket type: {socket_type}

What it means

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.

Source

Thrown at vllm/distributed/kv_transfer/kv_connector/v1/moriio/moriio_common.py:592

                or 0
            ),
            remote_dp_size=kv_transfer_params.get("remote_dp_size", 1),
            remote_dp_rank=kv_transfer_params.get("remote_dp_rank", 0),
            multi_pod_hosts=_pod_hosts,
            remote_dp_size_local=_remote_dp_size_local,
        )
        if write_mode:
            self.reqs_to_save[request_id] = _req
        else:
            self.reqs_to_recv[request_id] = _req


@contextlib.contextmanager
def zmq_ctx(socket_type: Any, addr: str) -> Iterator[zmq.Socket]:
    """Context manager for a ZMQ socket"""

    if socket_type not in (zmq.ROUTER, zmq.REQ, zmq.DEALER):
        raise ValueError(f"Unexpected socket type: {socket_type}")

    ctx: zmq.Context | None = None
    try:
        ctx = zmq.Context()  # type: ignore[attr-defined]
        yield make_zmq_socket(
            ctx=ctx, path=addr, socket_type=socket_type, bind=socket_type == zmq.ROUTER
        )
    finally:
        if ctx is not None:
            ctx.destroy(linger=0)

View on GitHub (pinned to c794754062)

Solutions

  1. Use one of the supported types: zmq.ROUTER (server/bind side) or zmq.REQ / zmq.DEALER (client/connect side)
  2. For genuinely different socket types, create the zmq.Context and make_zmq_socket call directly with explicit bind semantics

Example fix

// before
with zmq_ctx(zmq.PUB, path) as sock: ...

// after
with zmq_ctx(zmq.ROUTER, path) as sock: ...
Defensive patterns

Strategy: type-guard

Validate before calling

import zmq

assert socket_type in (zmq.ROUTER, zmq.REQ, zmq.DEALER), f"unsupported socket_type {socket_type}"

Type guard

import zmq

def is_supported_moriio_socket(t) -> bool:
    return t in (zmq.ROUTER, zmq.REQ, zmq.DEALER)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vllm-project/vllm@c794754062 (2026-08-14). Data as JSON: /api/errors/21a0daaa39f3df85. Report an issue: GitHub.