What Is Stream Mode
Stream mode is an integration method provided by the DingTalk Open Platform. It can listen for Bot callbacks, event subscription callbacks, and registered Card callbacks. When you integrate using Stream mode, the DingTalk Open Platform communicates with your app through a WebSocket connection. Stream mode greatly lowers the integration barrier and resource dependency. You do not need public network resources such as a server, IP address, or domain. Simply integrate the DingTalk Open Platform SDK.Stream Mode Principles
In Stream mode, your app integrates the SDK to establish a WebSocket connection with the DingTalk Open Platform. During the connection process, the Open Platform authenticates the connection. When a Card callback occurs, the Open Platform pushes the data to your app through the WebSocket connection. Your app can receive this data and process it accordingly, enabling real-time communication with the DingTalk Open Platform, as shown in the figure below.Advantages of Stream Mode
In scenarios where the DingTalk Open Platform sends requests to an app, most use the Webhook method (registering a public HTTPS service), including Card callbacks. Developing with the Webhook method involves many challenges, including:- Applying for a public domain and TLS certificate
- Applying for a public IP address and deploying an access gateway
- Deploying an application firewall and configuring an allowlist
- Handling request authentication as well as encryption and decryption on your own
- Setting up an intranet penetration environment for local development and debugging
- Zero Public IP You do not need to rely on or expose a public IP address or domain. This reduces the security risks of exposing services to the public network and lowers the development barrier.
- Zero Encryption/Decryption, Signature, or TLS Certificate Management Use the app identity to authenticate the connection and establish a TLS-encrypted connection with the DingTalk Open Platform through a reverse connection, providing a fast and secure communication experience.
- Zero Firewall Allowlist In Stream mode, you do not need to open any server ports to the public network, deploy a firewall, or configure an allowlist.
- Zero Gateway Deployment The channel is established through a reverse connection. You only need to ensure that the runtime environment has public network access. No gateway deployment is required.
- Zero Intranet Penetration You do not need to set up intranet penetration tools locally. With Stream mode, you can receive Card callbacks directly in your local development environment.
Integration Methods
Important The Client-side receives callbacks for the corresponding Card as soon as it starts. When deploying test and development environments, avoid affecting the production environment.Integration Limits
- The environment where your app is deployed must have public network access.
- Applicable only to internal apps and third-party enterprise apps.
- Each client instance enables one WebSocket connection by default, and an app can establish up to 50 connections by default.
Java
-
Runtime Environment
JDK 1.8 or later. -
Install the Java SDK
Add the dependency to your project’spom.xmlfile or download the corresponding JAR package. You can view and download the latest SDK version here. -
Sample Code
Bot CallbackFor details, see the Bot development documentation. Parameter DescriptionEvent Subscription CallbackFor details, see Configure Stream Push. Parameter DescriptionCard CallbackFor details, see Interactive Card Stream. Parameter Description
Golang
-
Runtime Environment
1.16 or later. -
Install the SDK
-
Sample Code
Bot CallbackParameter Description
Integration Methods in Other Languages
- Java SDK Sample Project
- Golang SDK and Sample Code
- Python SDK and Sample Code
- Node.js SDK and Sample Code