# reconnect_ws_stream

> **Function** in `langsmith`

📖 [View in docs](https://reference.langchain.com/python/langsmith/sandbox/_ws_execute/reconnect_ws_stream)

Reconnect to an existing command over WebSocket.

Returns a tuple of (message_iterator, control), same as run_ws_stream.
The iterator yields the server's ``started`` acknowledgement, then stdout,
stderr, exit, and error messages. That acknowledgement is the only evidence
a reattachment landed for a command producing no output, so it is forwarded
rather than dropped.

With the ring buffer reader server model, there is no replay/live
phase distinction and no deduplication needed. The server reads from
its ring buffer starting at the requested offsets and streams output
from there. If the requested offset is older than the buffer's
earliest data, the server sends from the earliest available offset.

## Signature

```python
reconnect_ws_stream(
    dataplane_url: str,
    api_key: Optional[str],
    command_id: str,
    *,
    stdout_offset: int = 0,
    stderr_offset: int = 0,
    headers: Optional[Mapping[str, str]] = None,
) -> tuple[Iterator[dict], _WSStreamControl]
```

---

[View source on GitHub](https://github.com/langchain-ai/langsmith-sdk/blob/ea8caba352b122b6f36fc5eaf45756ca00470e0a/python/langsmith/sandbox/_ws_execute.py#L392)