40006: Message contains invalid connection ID
message_contains_invalid_connection_idA published message referenced a connection by an ID or key that was invalid or did not match, so the message was rejected.
What you should do
When publishing on behalf of a realtime connection, make sure the connectionKey you publish with is the current key of that connection, and that any connectionId set on a message matches the publishing connection. Correct the mismatched value and resend.
Why it happens
A published message referenced a connection that couldn't be validated. Usual causes are a malformed or stale connectionKey, a REST publisher and realtime client that belong to different Ably apps or use different client IDs, or a manually constructed message whose connectionId doesn't match the current connection.
What you'll see
The error is reported with code 40006 and HTTP status 400. The message is typically Malformed message; invalid connectionId or Malformed message; mismatched connectionId.