disconnect

View as MarkdownOpen in Claude

Cleanly close the WebSocket connection to SignalWire RELAY. This cancels the internal ping loop, all pending JSON-RPC requests, any queued requests waiting for reconnection, and any in-progress dial operations. The client can be reconnected with connect().

When using run(), disconnection happens automatically on Ctrl+C or when a SIGTERM is received.

Parameters

None.

Returns

Promise<void>

Example

1import { RelayClient } from '@signalwire/sdk';
2
3const client = new RelayClient({
4 project: process.env.SIGNALWIRE_PROJECT_ID!,
5 token: process.env.SIGNALWIRE_TOKEN!,
6 contexts: ['default']
7});
8
9await client.connect();
10
11// Do work ...
12const message = await client.sendMessage({
13 to: '+15559876543',
14 from: '+15551234567',
15 body: 'Hello!',
16});
17await message.wait();
18
19await client.disconnect();