# Client sessions and machine network connectivity

When connecting to a machine using the connection code from the [**CONNECT** tab](https://docs.viam.com/reference/sdks/), a [client session](https://docs.viam.com/reference/apis/sessions/) automatically uses the most efficient route to connect to your machine either through local LAN or WAN or the internet.

## Connect over local network or offline

To connect directly to your local machine, you can use the connection code from the **CONNECT** tab if you are using the Python SDK, Go SDK, Flutter SDK, or C++ SDK.

For the TypeScript SDK, you must disable TLS on your `viam-server` and set `signalingInsecure: true` in the connection code:

- [Command-line](https://docs.viam.com/reference/sdks/connectivity/#tabset-referencesdksconnectivity-1-0)
- [Configuration](https://docs.viam.com/reference/sdks/connectivity/#tabset-referencesdksconnectivity-1-1)

Restart `viam-server` with the `-no-tls` flag.

1. Add `"no_tls": true` to the `"network"` section of your machine’s JSON configuration:

```json
   
   ```

Copy

2. Restart your machine.
   You can restart your machine by clicking on the machine status indicator in Viam and clicking **Restart**.

Update your connection code to set `signalingInsecure` to `true` and point the signaling address at your machine’s local address:

```ts

```

Copy

Port `8080` is the `viam-server` default; use a different port if your machine is configured to listen on one.

## Connectivity Issues

When a machine loses its connection to the internet but is still connected to a LAN or WAN:

- Client sessions connected through the same LAN or WAN will function normally.
- Client sessions connected through the internet will timeout and end.

If the client is on the same LAN or WAN but the route it chose to connect is through the internet, the client will automatically disconnect and then reconnect over LAN.

- Cloud sync for the [data management service](https://docs.viam.com/data/capture-sync/capture-and-sync-data/) will pause until the internet connection is re-established since the machine will be unable to connect to Viam.

When a machine loses its connection to LAN or WAN, all client sessions will timeout and end by default.

### Client session timeout and end

When your client cannot connect to your machine’s `viam-server` instance, `viam-server` will end any current client [_sessions_](https://docs.viam.com/reference/apis/sessions/) on this machine and all client operations will [time out automatically](https://docs.viam.com/reference/apis/sessions/) and halt: any active commands will be cancelled, stopping any moving parts, and no new commands will be able to reach the machine until the connection is restored.

To disable the default behavior and manage resource timeout and reconfiguration over a networking session yourself, you can [disable the default behavior](https://docs.viam.com/reference/apis/sessions/#disable-default-session-management) of session management, then use [Viam’s SDKs](https://docs.viam.com/reference/sdks/) in your code to make calls to [the session management API](https://pkg.go.dev/go.viam.com/rdk/session#hdr-API).

#### Note

There are a couple of exceptions to the general timeout behavior:

- If a [`MoveOnMap`](https://docs.viam.com/reference/apis/services/motion/#moveonmap) or [`MoveOnGlobe`](https://docs.viam.com/reference/apis/services/motion/#moveonglobe) command has completed a motion plan and returned an execution ID before the connection is lost, the resource that receives the motion plan will complete the motion without a connection.
- If a navigation service and motion service are running on the same machine, the navigation service will continue sending requests to the motion service even after losing internet connectivity.

### Configure a connection timeout

When connecting to a machine using the [robot API](https://docs.viam.com/reference/apis/robot/) from a supported [Viam SDK](https://docs.viam.com/reference/apis/), you can configure an [optional timeout](https://docs.viam.com/reference/apis/sessions/#change-the-session-timeout) to account for intermittent or delayed network connectivity.
