Hello,
Facing a strange issue. After upgrading to EventSub websockets from PubSub, some of our users reported that they cannot subscribe to any Twitch events, logs below:
[TwitchWebSocketClient] Connecting to EventSub WebSocket
[TwitchWebSocketClient] WebSocket connection established
[TwitchWebSocketClient] Received message: {"metadata":{"message_id":"c01c0a3e-93e9-4ed9-8f88-f53f0b83c6ca","message_type":"session_welcome","message_timestamp":"2025-03-28T06:58:50.22334164Z"},"payload":{"session":{"id":"AgoQ5vFpwH7QQxGDR1L5my0WmxIGY2VsbC1i","status":"connected","connected_at":"2025-03-28T06:58:50.219147346Z","keepalive_timeout_seconds":10,"reconnect_url":null,"recovery_url":null}}}
[TwitchWebSocketClient] [TwitchWebSocketClient] Session established with ID: AgoQ5vFpwH7QQxGDR1L5my0WmxIGY2VsbC1i
[TwitchWebSocketClient] Failed to subscribe to channel.channel_points_custom_reward_redemption.add: HTTP/1.1 429 Too Many Requests
{"error":"Too Many Requests","status":429,"message":"number of websocket transports limit exceeded"}
Relevant code:
public async UniTask CreateEventSubSubscription(string type, string version, Dictionary < string, string > condition, string sessionId) {
var subscription = new {
type,
version,
condition,
transport = new {
method = "websocket",
session_id = sessionId
}
};
string jsonPayload = JsonConvert.SerializeObject(subscription);
using
var uwr = new UnityWebRequest(EventSubCreateSubscriptionUrl, UnityWebRequest.kHttpVerbPOST);
uwr.SetRequestHeader("Client-ID", ClientId);
uwr.SetRequestHeader("Authorization", $ "Bearer {AccessToken}");
uwr.SetRequestHeader("Content-Type", "application/json");
uwr.downloadHandler = new DownloadHandlerBuffer();
uwr.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(jsonPayload));
try {
await uwr.SendWebRequest();
if (uwr.result == UnityWebRequest.Result.ConnectionError ||
uwr.result == UnityWebRequest.Result.ProtocolError) {
Debug.LogError($"[TwitchPlugin] EventSub Error: {uwr.error}, Response: {uwr.downloadHandler.text}");
// 401 Unauthorized?
if (uwr.responseCode == 401) {
Debug.Log("[TwitchPlugin] OAuth token is invalid, refreshing");
await client.RefreshToken();
await CreateEventSubSubscription(type, version, condition, sessionId);
}
} else {
Debug.Log($"[TwitchPlugin] EventSub Subscription Created: {type}");
}
} catch (Exception e) {
Debug.LogError($"[TwitchPlugin] Error creating EventSub subscription: {e.Message}");
throw;
}
}
The strange part is, this only happens to some of our users. I can never reproduce this on my end using my account. Some more details:
- For both working and non-working users, the
AccessToken
is freshly acquired. - For both working and non-working users, the same events are subscribed, but for the non-working users, they fail subscribing to the very first event.
- I thought this is a “our app has too many concurrent users” issue, but I have tried subscribing to EventSub at the same time as the other user (with different Twitch accounts, of course), and I succeeded while they had a 429.
Can any Twitch engineers explain the error (number of websocket transports limit exceeded
) and suggest what might lead to it? That’d be really appreciated. Thanks!