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

fix(api): emulator proxy client uri logic #12778

Merged
merged 3 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion api/src/opentrons/hardware_control/emulation/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import logging
import uuid
import socket
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import List
Expand Down Expand Up @@ -115,10 +116,17 @@ async def _handle_server_connection(
connection = Connection(
identifier=str(uuid.uuid1()), reader=reader, writer=writer
)

log.info(f"Using Local Host: {self._settings.use_local_host}")

client_host = (
"127.0.0.1" if self._settings.use_local_host else socket.gethostname()
)

self._cons.append(connection)
self._event_listener.on_server_connected(
server_type=self._name,
client_uri=f"socket:https://127.0.0.1:{self._settings.driver_port}",
client_uri=f"socket:https://{client_host}:{self._settings.driver_port}",
identifier=connection.identifier,
)

Expand Down
1 change: 1 addition & 0 deletions api/src/opentrons/hardware_control/emulation/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ProxySettings(BaseModel):
host: str = "0.0.0.0"
emulator_port: int
driver_port: int
use_local_host: bool = True


class ModuleServerSettings(BaseModel):
Expand Down