Error codes

Connection and channel errors

thunderclapJS reports these codes through error events: connection-level errors on the client (thunderclap.on("error")), channel errors on the channel (channel.on("error")).

CodeScopeMeaningWhat happens
4001ConnectionUnknown app keyFails for good: check THUNDERCLAP_KEY
4003ConnectionThe app is suspendedFails for good until the app is reactivated
4009ConnectionConnection token invalid or expiredFails for good: check the token your backend issues
4100ConnectionOver capacity, or too many connections opened at once for the appRetries with backoff
4101ConnectionThe app reached its plan's connection limit (Spark)Retries with backoff, connecting once a place frees up
4200ConnectionReconnect now (maintenance or rebalancing)Reconnects at once, automatically
4300ChannelMalformed frameThe connection stays open
4301ChannelInvalid channel nameThe subscription is refused
4302ChannelNot authorized for this private or presence channel (presence also needs a user id)The subscription is refused
4303ChannelToo many subscriptions on one connection (100)The subscription is refused
4304ChannelInternal error while handling the channelTry subscribing again
4305ChannelThe presence channel is full (100 members)The subscription is refused
4306ChannelA client event was refused: disabled for the app, public channel, not subscribed, bad name, too large or too manyThe event is dropped

Codes from 4000 to 4099 are final: the client moves to the failed state and stops reconnecting. Codes from 4100 to 4199 are retried with backoff, 4200 to 4299 reconnect at once, and 4300 and up concern one channel while the connection stays open.

Server SDK errors

@thunderclapjs/server throws a ThunderclapApiError with the HTTP status and a message:

StatusMeaning
400Invalid input: channel or event name, data too large, too many channels or events
401Wrong app id or secret, or the app is suspended
429Too many requests: either the app used up its plan's messages for the month (Spark), which resumes next month or once the organisation upgrades, or it sent more than 1,000 requests a second, which resumes after the Retry-After delay
5xxTemporary failure: retry

Webhook verification throws a ThunderclapWebhookError instead. See the server reference.