Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] use AF_INET6 instead of AF_INET for OpenAI Compatible Server #9583

Merged
merged 10 commits into from
Nov 15, 2024
17 changes: 14 additions & 3 deletions vllm/entrypoints/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from contextlib import asynccontextmanager
from functools import partial
from http import HTTPStatus
from typing import AsyncIterator, Set
from typing import AsyncIterator, Set, Tuple

import uvloop
from fastapi import APIRouter, FastAPI, Request
Expand Down Expand Up @@ -524,6 +524,17 @@ def init_app_state(
)


def create_server_socket(addr: Tuple[str, int]) -> socket.socket:
if socket.has_dualstack_ipv6():
sock = socket.create_server(addr,
family=socket.AF_INET6,
dualstack_ipv6=True)
jxpxxzj marked this conversation as resolved.
Show resolved Hide resolved
else:
sock = socket.create_server(addr)

return sock


async def run_server(args, **uvicorn_kwargs) -> None:
logger.info("vLLM API server version %s", VLLM_VERSION)
logger.info("args: %s", args)
Expand All @@ -540,8 +551,8 @@ async def run_server(args, **uvicorn_kwargs) -> None:
# workaround to make sure that we bind the port before the engine is set up.
# This avoids race conditions with ray.
# see https://github.com/vllm-project/vllm/issues/8204
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("", args.port))
sock_addr = ("", args.port)
sock = create_server_socket(sock_addr)
jxpxxzj marked this conversation as resolved.
Show resolved Hide resolved

def signal_handler(*_) -> None:
# Interrupt server on sigterm while initializing
Expand Down