Skip to main content

Disconnect

Closes the connection to Gate.io exchange and releases associated resources. This node should be used at the end of your Gate.io automation workflow to properly clean up the client session.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Client Id - The unique client identifier returned by the Connect node. This identifies which connection to close.

How It Works

The Disconnect node cleans up the Gate.io client session when your automation workflow is complete.

When executed, the node:

  1. Retrieves the Client Id from the input
  2. Validates that the Client Id is not empty
  3. Looks up the corresponding client session in memory
  4. Removes the client session from memory
  5. Releases all associated resources

Requirements

  • A valid Client Id from a Connect node
  • The client session must still exist (not already disconnected)

Error Handling

The node will return specific errors in the following cases:

  • ErrInternal - Failed to retrieve Client Id from inputs
  • ErrInvalidArg - Client Id is empty

Usage Notes

  • Always use Disconnect at the end of your Gate.io automation flow
  • Each Connect node should have a corresponding Disconnect node
  • The Disconnect node should be executed even if errors occur during the workflow
  • Use a Finally node or error handling to ensure Disconnect always runs
  • Once disconnected, the Client Id becomes invalid and cannot be reused
  • The client is automatically removed when the flow stops, but explicit disconnection is best practice

Best Practices

  • Always pair Connect with Disconnect nodes
  • Place Disconnect in a Finally block to ensure it runs even if errors occur
  • Use a single Disconnect node at the end of your flow
  • Don't try to reuse a Client Id after disconnection
  • Monitor your flow to ensure Disconnect is always reached

Example Flows

Basic Flow

[Connect] -> [Get Price] -> [Buy Order] -> [Disconnect]

With Error Handling

[Connect] -> [Try]
|
+-> [Get Balance]
+-> [Buy Order]
|
+-> [Catch] -> [Log Error]
|
+-> [Finally] -> [Disconnect]

This ensures the connection is always properly closed, even if errors occur during operations.

Multiple Operations

[Connect]
|
+-> [Get Balance]
+-> [Get Price: BTC_USDT]
+-> [Get Price: ETH_USDT]
+-> [List My Orders]
+-> [Get Fee]
|
+-> [Disconnect]

Use a single Connect/Disconnect pair for multiple operations to reuse the same client session.

Common Patterns

Safe Cleanup Pattern

[Connect] -> Store Client Id in variable
|
+-> [Try Block]
| |
| +-> [Your Gate.io Operations]
|
+-> [Finally Block]
|
+-> [Disconnect] (uses stored Client Id)

Conditional Disconnect

[Connect] -> [If: Success]
|
+-> True: [Process Results] -> [Disconnect]
+-> False: [Log Error] -> [Disconnect]

Ensure Disconnect is called in all branches.

Resource Management

The Disconnect node is important for:

  • Memory Management: Removes client sessions from memory
  • Clean Shutdown: Ensures proper cleanup of API connections
  • Resource Limits: Prevents accumulation of unused client sessions
  • Best Practices: Follows proper connection lifecycle management

Troubleshooting

Client Id Not Found

If you receive an error that the Client Id is invalid:

  • Verify the Client Id is being passed correctly from Connect node
  • Check that Disconnect hasn't already been called
  • Ensure the Connect node executed successfully

Memory Cleanup

Even without explicit Disconnect:

  • Client sessions are automatically cleaned up when the flow stops
  • However, explicit disconnection is recommended for proper resource management
  • Long-running flows should always use Disconnect to free resources
  • Connect - Creates the client session that this node closes
  • All Gate.io Nodes - All trading and data nodes use the Client Id between Connect and Disconnect