def METHOD_NAME(unused_tcp_port, ws):
    # if the duplexer is immediately stopped, it should be well behaved and close
    # the connection normally
    closed = Event()
    async def handler(websocket, path):
        try:
            await websocket.recv()
        except ConnectionClosedOK:
            closed.set()
    ws("localhost", unused_tcp_port, handler)
    duplexer = SyncWebsocketDuplexer(
        f"ws://localhost:{unused_tcp_port}",
        f"ws://localhost:{unused_tcp_port}",
        None,
        None,
    )
    duplexer.stop()
    assert closed.wait(10)