Skip to content

Advanced networking and performance

Same-device loopback is the recommended development path. Use authenticated LAN access only when the controller must run on another computer.

Connect from another computer on the LAN

Keep the API key outside source control:

import os

from sim2bot import Robot


def main() -> None:
    token = os.environ["SIM2BOT_API_KEY"]
    with Robot(
        url="ws://192.168.1.50:8765/ws",
        video_url="ws://192.168.1.50:8765/video",
        api_key=token,
        room="lab-a",
        wait_for_sim=True,
        wait_for_sim_timeout=30.0,
    ) as sim:
        for robot in sim.describe():
            print(robot.index, robot.id, robot.name)


if __name__ == "__main__":
    main()

Select latest-value UDP control and telemetry

from sim2bot import Robot


with Robot(
    transport="udp",
    udp_host="192.168.1.50",
    udp_port=8771,
    room="lab-a",
    wait_for_sim=True,
) as sim:
    arm = sim.describe()[0]
    sim.move_to(arm.home, robot=arm.index)

UDP avoids reliable-stream head-of-line delay, but it does not make the browser simulation a hard real-time controller. Commands remain latest-value, physics is currently scheduled by the browser frame loop, and hidden tabs can be throttled.

Do not expose the bridge publicly

The authenticated bridge feature is intended for a trusted local network. Public internet access needs a separately designed secure gateway, TLS, authorization, rate limits, observability, and revocation.

Relevant guides and APIs