Skip to content

Commit

Permalink
[Core] zmq: bind only to 127.0.0.1 for local-only usage (vllm-project…
Browse files Browse the repository at this point in the history
…#8543)

Signed-off-by: Russell Bryant <rbryant@redhat.com>
  • Loading branch information
russellb authored and MengqingCao committed Sep 30, 2024
1 parent d7cf6f8 commit b3b62d7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions vllm/distributed/device_communicators/shm_broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ def __init__(
# see http://api.zeromq.org/3-3:zmq-setsockopt for more details
self.local_socket.setsockopt(XPUB_VERBOSE, True)
local_subscribe_port = get_open_port()
self.local_socket.bind(f"tcp://*:{local_subscribe_port}")
socket_addr = f"tcp://127.0.0.1:{local_subscribe_port}"
logger.debug("Binding to %s", socket_addr)
self.local_socket.bind(socket_addr)

self.current_idx = 0

Expand All @@ -212,7 +214,8 @@ def __init__(
self.remote_socket = context.socket(XPUB)
self.remote_socket.setsockopt(XPUB_VERBOSE, True)
remote_subscribe_port = get_open_port()
self.remote_socket.bind(f"tcp://*:{remote_subscribe_port}")
socket_addr = f"tcp://*:{remote_subscribe_port}"
self.remote_socket.bind(socket_addr)

else:
remote_subscribe_port = None
Expand Down Expand Up @@ -255,8 +258,9 @@ def create_from_handle(handle: Handle, rank) -> "MessageQueue":

self.local_socket = context.socket(SUB)
self.local_socket.setsockopt_string(SUBSCRIBE, "")
self.local_socket.connect(
f"tcp://{handle.connect_ip}:{handle.local_subscribe_port}")
socket_addr = f"tcp://127.0.0.1:{handle.local_subscribe_port}"
logger.debug("Connecting to %s", socket_addr)
self.local_socket.connect(socket_addr)

self.remote_socket = None
else:
Expand All @@ -270,8 +274,9 @@ def create_from_handle(handle: Handle, rank) -> "MessageQueue":

self.remote_socket = context.socket(SUB)
self.remote_socket.setsockopt_string(SUBSCRIBE, "")
self.remote_socket.connect(
f"tcp://{handle.connect_ip}:{handle.remote_subscribe_port}")
socket_addr = f"tcp://{handle.connect_ip}:{handle.remote_subscribe_port}"
logger.debug("Connecting to %s", socket_addr)
self.remote_socket.connect(socket_addr)

return self

Expand Down

0 comments on commit b3b62d7

Please sign in to comment.