sgl-project/sglang · error · ValueError
Unsupported socket type: {socket_type}
Error message
Unsupported socket type: {socket_type} What it means
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.
Source
Thrown at python/sglang/srt/utils/network.py:264
buf_size = -1
def set_send_opt():
socket.setsockopt(zmq.SNDHWM, 0)
socket.setsockopt(zmq.SNDBUF, buf_size)
def set_recv_opt():
socket.setsockopt(zmq.RCVHWM, 0)
socket.setsockopt(zmq.RCVBUF, buf_size)
if socket_type == zmq.PUSH:
set_send_opt()
elif socket_type == zmq.PULL:
set_recv_opt()
elif socket_type in [zmq.DEALER, zmq.REQ, zmq.REP, zmq.PAIR]:
set_send_opt()
set_recv_opt()
else:
raise ValueError(f"Unsupported socket type: {socket_type}")
def get_local_ip_by_nic(interface: str = None) -> Optional[str]:
if not (interface := interface or os.environ.get("SGLANG_LOCAL_IP_NIC", None)):
return None
try:
import netifaces
except ImportError as e:
raise ImportError(
"Environment variable SGLANG_LOCAL_IP_NIC requires package netifaces, please install it through 'pip install netifaces'"
) from e
try:
addresses = netifaces.ifaddresses(interface)
if netifaces.AF_INET in addresses:
for addr_info in addresses[netifaces.AF_INET]:
ip = addr_info.get("addr")
if ip and ip != "127.0.0.1" and ip != "0.0.0.0":View on GitHub (pinned to 0132848349)
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.
Example fix
# before sock = get_zmq_socket(ctx, zmq.XPUB, endpoint) # after sock = ctx.socket(zmq.XPUB) sock.set(zmq.SNDHWM, 1000) sock.bind(endpoint)
Defensive patterns
Strategy: validation
Validate before calling
import zmq
SUPPORTED = {zmq.PUSH, zmq.PULL, zmq.PUB, zmq.SUB, zmq.DEALER, zmq.REQ, zmq.REP, zmq.PAIR}
assert socket_type in SUPPORTED, f"configure {socket_type} manually" Prevention
- For exotic socket types, configure setsockopt manually instead of config_socket.
When it happens
Trigger: 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.
Common situations: User code adding a custom ZMQ transport (proxy, monitor, XPUB/XSUB bus) routed through sglang's socket helper.
Related errors
- Unsupported socket type: {socket_type}
- Could not bind port {port} on any configured address family
- Failed to get server info. {error_data['error']['message']}
- Failed to get model info: {str(e)}
- Failed to edit image: {str(e)}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/146ba86e79681d1f.
Report an issue: GitHub.