from polynode.ws import PolyNodeWS
from polynode.types.ws import WsOptions
ws = PolyNodeWS("pn_live_...", "wss://ws.polynode.dev/ws", WsOptions(
compress=True,
auto_reconnect=True,
max_reconnect_attempts=0, # 0 = unlimited
reconnect_base_delay=1.0, # seconds
reconnect_max_delay=30.0, # seconds
))
ws.on_connect(lambda: print("connected"))
ws.on_disconnect(lambda reason: print(f"disconnected: {reason}"))
ws.on_reconnect(lambda attempt: print(f"reconnected, attempt {attempt}"))
ws.on_error(lambda err: print(f"error: {err}"))