1. Ably FAQs
  2. Channels
  3. Subscribing and publishing

Is there a maximum number of channels per connection?

If you ever receive the following error message, it means you've hit your limit on channels per connection:

[ErrorInfo: Maximum number of channels per connection MAXCHANNELS exceeded; statusCode=90010; code=400]

Where MAXCHANNELS is the maximum number of channels per connection you're allowed.


This is to be expected if you're attempting to use more channels per connection than your limit allows.  We impose a limit to ensure that the connection state and the load imposed for connection resumption don't become unbounded. With more channels on a single connection, the size of the connection state grows, as does the work required to resume or recover the connection if dropped, both for the client and the Ably server.


There are a few ways to avoid reaching your limit:

  • If you're using a client library that supports transient publishes (ably-js >= 1.0.9, ably-ruby >= 1.1, ably-java >= 1.0.10), and you only need to publish on the channel (not receive messages from it), then you can just call channel#publish without attaching to the channel, and avoid the channel limit altogether.
  •  If you're only using the channel for a short period of time, make sure to detach it once you're finished with it using channel#detach. Remember, subscribing to a channel (and, in libraries that don't support transient publishing, publishing) will implicitly attach to it, so by detaching after these actions you can keep your channels per connection to a minimum.
  • If you are using the REST library, you never attach to a channel as all the actions are completely stateless. So if you are only publishing to a channel, and the rate at which you publish on a channel is low or you're on a platform where the realtime library does not yet support transient publishes, you may wish to use REST publishes instead.


If you genuinely need to attach many hundreds of channels simultaneously with one client using the Realtime library, you should consider sharding the channels across multiple connections. Otherwise, you are able to configure this limit with an Enterprise account.


Further reading: