Echo

Open in

By default, clients receive their own messages when subscribed to a channel they publish on. This is useful in many applications because it means every subscriber, including the publisher, renders state from the same stream of messages. For example, in a chat application or collaborative editor, a client can publish a message and then update its UI only when that message arrives back on the channel, guaranteeing that all participants see the same ordering and state.

However, this is not always desirable. A client streaming pricing updates, publishing telemetry data, or sending tokens via AI Transport does not need to hear its own messages echoed back. Suppressing echo on these channels reduces unnecessary bandwidth and message processing.

Set echo to false in the channel params to suppress echo on a per-channel basis. As echo only applies to channel subscriptions, it is only available when using the realtime interface of an Ably SDK, or when using SSE or MQTT.

When to suppress echo

Suppressing echo per-channel is useful when a client publishes and subscribes on the same channel but does not need its own messages back:

  • Streaming data: A client publishing live pricing updates, sensor readings, or telemetry to a channel does not need those messages echoed back. Suppressing echo avoids redundant processing and reduces bandwidth.
  • AI token streaming: An AI Transport agent publishes tokens at high frequency and subscribes for steering or control messages. Echoing every token back to the publishing agent is wasteful.
  • RPC over channels: A caller publishes a request and subscribes for the response on the same channel. The caller already knows what it sent.
  • Mixed workloads: Some channels on a connection need echo, such as collaborative editing where a client confirms its updates, while others do not, such as notification or logging channels.

The connection-level echoMessages option disables echo across all channels on a connection. The echo channel param provides finer control, disabling echo on specific channels while leaving others unaffected.

Suppress echo on a channel

Set the echo param to false when obtaining a channel instance:

Realtime

1

2

3

4

5

6

7

8

const channel = realtime.channels.get('pet-ink-one', {
  params: { echo: 'false' }
});

await channel.subscribe((message) => {
  // Only receives messages from other clients, not from this client
  console.log('Received:', message.data);
});

Interaction with connection-level echo

The channel-level echo param works alongside the connection-level echoMessages setting:

Connection echoMessagesChannel echo paramResult
true (default)Not setMessages echoed
true (default)falseMessages suppressed on this channel
falseNot setMessages suppressed (connection-level)
falsefalseMessages suppressed

The channel-level param only adds suppression. If the connection already has echoMessages set to false, echo is suppressed regardless of the channel param.