<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [sip.js](./sip.js.md) &gt; [Transport](./sip.js.transport.md) &gt; [onDisconnect](./sip.js.transport.ondisconnect.md)

## Transport.onDisconnect property

Callback on state transition from "Connected".

<b>Signature:</b>

```typescript
onDisconnect: ((error?: Error) => void) | undefined;
```

## Remarks

When the `UserAgent` is constructed, this property is set.

```txt
- The `state` MUST NOT "Connected" when called.
- If prior `state` is "Connecting" or "Connected", `error` MUST be defined.
- If prior `state` is "Disconnecting", `error` MUST NOT be undefined.

```
If the transition from "Connected" occurs because the transport user requested it by calling `disconnect`<!-- -->, then `error` will be undefined. Otherwise `error` will be defined to provide an indication that the transport initiated the transition from "Connected" - for example, perhaps network connectivity was lost.

