# 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 stdout, stderr, exit, and error messages.
No 'started' message is sent on reconnection.

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/cf0366388873e33ef593235c1d0c7e561db79cfb/python/langsmith/sandbox/_ws_execute.py#L319)