Idempotent publishing (docs) is now enabled in all Ably 1.1 Client Library SDKs. This elimimates the risk of duplicate messages.
What is idempotent publishing?
Idempotent REST publishing ensures that a failed publish due to a network failure, or any other failure, can safely be retried without worrying that a message may be published more than once.
In effect, we’re adding exactly-once semantics to our REST publishes over a protocol (HTTP) that has historically had shortcomings at a protocol level in regards to idempotent operations.
The problem is that POST, which is most commonly used to create or upload resources, is not guaranteed to be idempotent. Therefore, HTTP clients that send a POST request to a server more than once should expect multiple results.
In the world of distributed systems and services that provide contracts in terms of what onwards processing happens for POST requests, this can be a considerable problem. For example, if an HTTP client is publishing a message containing transaction details into a pub/sub system that is then in turn broadcasting that message to subscribers, publishing the message multiple times will mistakenly result in the transaction being processed multiple times.
Ably's idempotent publishing solves this.
Note: When we released the Ably 1.1 client library SDKs, idempotent publishing was supported in all libraries but wasn't yet enabled. If you're already using a 1.1 library there's no need to need to upgrade.