# LibTmux.Control.reconnect/2

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/lib/libtmux/control.ex#L487
- **Page:** https://libtmux.org/en/elixir/pr-173/reference/libtmux-control-reconnect-2/

```
reconnect(control, options \\ [])
@spec reconnect(t(), [call_option()]) ::
        {:ok, t()} | {:error, LibTmux.Error.t()}
```

Explicitly obtains the ready epoch, starting a replacement only after retirement.

A ready epoch returns itself. Call `close/2` first to require replacement.
The default 5000ms budget covers metadata admission, retirement and startup.
A successful reply pins the acknowledged endpoint even if it becomes stale
before this caller resumes. It never follows a later view or replays work.
Errors report unknown certainty about existing effects. Attachment counts
include the control client; reconnect can attach one replacement client.

See the [worked example](supervised-control.html).

## Parameters

- `control` (`t()`)
- `options` (`[call_option()]`)
  Default: `[]`.

## tmux command

The tmux commands behind `reconnect/2`.

- [`attach-session`](/en/tmux/latest/manual/attach-session/) (the connection is closed)
- [`display-message`](/en/tmux/latest/manual/display-message/) (the connection is closed)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_attach_session_entry`](/en/tmux/latest/reference/c-variable-cmd_attach_session_entry/) (attribute)
- [`cmd_attach_session_exec`](/en/tmux/latest/reference/c-function-cmd-attach-session-c-cmd_attach_session_exec/) (function)
- [`cmd_display_message_entry`](/en/tmux/latest/reference/c-variable-cmd_display_message_entry/) (attribute)
- [`cmd_display_message_exec`](/en/tmux/latest/reference/c-function-cmd-display-message-c-cmd_display_message_exec/) (function)

## Guides

Pages that discuss `reconnect/2`.

### Concepts

- [Read values, execute explicitly](/en/elixir/pr-173/concepts/mental-model/)

### Topics

- [Execution ownership](/en/elixir/pr-173/topics/ownership/)
