I’m creating an application that need access to some channel events (such as new followers, stream start, and so on). So I’m using EventSub with a Websockets (By the way thanks for adding this that’s exactly what I was searching a way around since a month) but as soon as I try to subscribe to an event the server answer me “websocket transport session does not exist or has already disconnected”.
Here is my process:
I connected with a Websocket to wss://eventsub-beta.wss.twitch.tv/ws
Sounds like you connected to eventsub websockets
got the session_id
disconnected from the websockets socetk
attempted to make subscriptions to a dead connection.
You need to connect to the WebSocket and within 10 seconds make subscription requests.
If you make no subscription requests within the 10 seconds then you will have been disconnected from the Twitch Socket Server.
The POST request was send on receiving the session_welcome message, so in less than 10 seconds. You can see it with the Twitch timestamps showing roughly 1 seconds between the session_welcome and the HTTP 400 response.
And I didn’t close by myself the websocket so I don’t understand why it fails
So I can’t see anything wrong with what you have said is your order of operations.
The only thing I can think of is that your POST request to make a subscription. Is malformed. You declared a ContentType header of JSON but the message is not quite built nicely perhaps?
Not sure since this is just a Curl log. Are you just building command line CURL requests or a language to make HTTP calls?
I’m using my own C# library to make the request, the same library I used with the Twitch API (appart from issue on my side with receiving chunked package it works as expected). But I see in the RFC 0016 it sends the session id as field “id” and not “session_id”. Do you have a complete example of the content sent to the server by the client (like that I could see what I am missing in my library) ?
Thanks for your help I found out where my issue was. The issue I add was that the pong I sent back to the server weren’t masked, leading the server to close my connection. I changed that and now it works