Overview
When Ant Media Server runs in cluster mode, nodes communicate with each other using internal REST APIs. These endpoints are hidden from public documentation and are automatically called by the cluster infrastructure. Base Path:/cluster-communication
Publish Started Notification
Notifies other cluster nodes when streaming starts on a node.POST /cluster-communication/publish-started-notification/{id}
Stream ID that started publishing
Role of the stream (e.g.,
publisher, player)Main track ID if this is a subtrack
Whether notification was received successfully
When This is Called
- A stream starts publishing on Node A
- Node A notifies all other cluster nodes (B, C, D, etc.)
- Other nodes update their internal state to know where the stream is located
- Players on other nodes can be redirected to the correct origin node
Publish Stopped Notification
Notifies other cluster nodes when streaming stops on a node.POST /cluster-communication/publish-stopped-notification/{id}
Stream ID that stopped publishing
Role of the stream
Main track ID if this is a subtrack
Whether notification was received successfully
When This is Called
- A stream stops publishing on Node A
- Node A notifies all other cluster nodes
- Other nodes update their state to mark the stream as inactive
- New publish attempts can create a fresh stream on any node
Virtual Stream Data Message
Forwards data channel messages from virtual streams (conferences) between nodes.POST /cluster-communication/virtual-stream-data-message/{id}/{binary}
Virtual stream (conference room) ID
Whether the data is binary (
true) or text (false)Raw message data to forward
Whether message was forwarded successfully
When This is Called
- User on Node A sends a data channel message in a conference
- The message needs to reach participants on Node B
- Node A forwards the message to Node B via this endpoint
- Node B delivers it to local conference participants
Virtual streams (conferences) do not have internal cluster audio/video communication - only data messages are forwarded this way.
Cluster Architecture
How Cluster Communication Works
Request Flow
- Event occurs on origin node (stream start/stop, data message)
- Origin node sends notification to all other cluster nodes
- Receiving nodes update their internal state
- State synchronization allows proper routing of play requests
Authentication
Cluster communication uses internal JWT tokens that are:- Generated automatically by the cluster infrastructure
- Different from public API tokens
- Not exposed to external clients
- Validated using cluster-shared secrets
Cluster Configuration
These endpoints are automatically activated when cluster mode is enabled. Configuration is done in server settings:Monitoring Cluster Communication
You can monitor cluster communication in the server logs:Security Considerations
Network Security
- Private network - Cluster nodes should communicate over a private network
- Firewall rules - Restrict cluster communication ports to known node IPs
- TLS encryption - Use HTTPS for all cluster communication
- Token validation - Ensure internal tokens are properly validated
Best Practices
- Keep cluster communication on a separate network interface
- Monitor cluster communication logs for anomalies
- Regularly rotate cluster authentication secrets
- Use network segmentation to isolate cluster traffic
Troubleshooting
Common Issues
Nodes not receiving notifications:- Check network connectivity between nodes
- Verify firewall rules allow cluster communication
- Ensure all nodes have correct cluster configuration
- Check MongoDB connectivity (shared state)
- Verify conference room exists on both nodes
- Check cluster communication logs
- Ensure binary/text flag matches message type
- Verify cluster secret is identical on all nodes
- Check token expiration settings
- Ensure system clocks are synchronized (NTP)
