# LibTmux.PsmuxServer.GetSessionAsync

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** C#
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-dotnet/blob/cf34b255c896d19a97e7d7fabea58609c916012d/src/LibTmux/Psmux/PsmuxServer.cs#L85
- **Page:** https://libtmux.org/en/csharp/latest/reference/libtmux-psmuxserver-getsessionasync/

```
LibTmux.PsmuxServer.GetSessionAsync(cancellationToken: CancellationToken) -> Task<PsmuxSession>
```

Reads the sole visible session.

## Parameters

- `cancellationToken` (`CancellationToken`): Cancels the psmux query.

## Returns

The current immutable session observation.

## Raises

- [`InvalidOperationException`](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception): The selected namespace no longer has one live session.
- [`StaleServerGenerationException`](/en/csharp/latest/reference/libtmux-staleservergenerationexception/): The sole session was replaced after this server was connected.
- [`NotSupportedException`](https://learn.microsoft.com/dotnet/api/system.notsupportedexception): The selected namespace contains more than one session.
- [`LibTmuxException`](/en/csharp/latest/reference/libtmux-libtmuxexception/): The verified client could not complete the query.
