For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • BedrockAgent
      • CLI Tools
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions
      • LiveWire
      • MCP Gateway
      • PomBuilder
      • Prefabs
      • Search
      • SkillBase
      • Skills
      • SWAIGFunction
      • SWMLBuilder
      • SWMLService
      • WebService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
        • connect
        • dial
        • disconnect
        • execute
        • receive
        • run
        • send_message
        • unreceive
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • Chat
      • Compat
      • Datasphere
      • Fabric
      • Imported Numbers
      • Logs
      • Lookup
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSub
      • Queues
      • Recordings
      • Registry
      • RestClient
      • Short Codes
      • SignalWireRestError
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
RELAYRelayClient

disconnect

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

execute

Next
Built with

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

When using the async context manager (async with client:), disconnect() is called automatically on exit. When using run(), disconnection happens automatically on Ctrl+C or when the event loop is stopped.

Parameters

None.

Returns

None

Example

1import asyncio
2from signalwire.relay import RelayClient
3
4client = RelayClient(
5 project="your-project-id",
6 token="your-api-token",
7 host="your-space.signalwire.com",
8 contexts=["default"],
9)
10
11async def main():
12 await client.connect()
13
14 # Do work ...
15 message = await client.send_message(
16 to_number="+15559876543",
17 from_number="+15551234567",
18 body="Hello!",
19 )
20 await message.wait()
21
22 await client.disconnect()
23
24asyncio.run(main())