Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forwarding events carried over after WebSocket reconnect doesn't work #315

Closed
Xemdo opened this issue Mar 12, 2024 · 1 comment · Fixed by #318
Closed

Forwarding events carried over after WebSocket reconnect doesn't work #315

Xemdo opened this issue Mar 12, 2024 · 1 comment · Fixed by #318
Labels
bug Something isn't working

Comments

@Xemdo
Copy link
Contributor

Xemdo commented Mar 12, 2024

What is the problem?

When running the mock WebSocket server in strict mode (twitch event websocket start -S), it is noticed that after the mock server restarts via reconnect testing the subscriptions carry over seemingly correctly, but cannot be forwarded like they did before the WebSocket reconnected.

This happens when forwarding to a specific session as well as forwarding to all clients. The relevant commands are:

> twitch event trigger channel.ban --transport=websocket
> twitch event trigger channel.ban --transport=websocket --session=<session_id>

Operating System

All

Architecture Version (x86, x64, arm, etc)

All

Steps to reproduce

  1. Start mock websocket server with -S
  2. Connect websocket client
  3. Subscribe to any event
  4. Confirm forwarding that event works
  5. Run reconnect testing
  6. Reconnect the WebSocket client to the URL provided by the reconnect message
  7. Verify event subscription exists
  8. Attempt to forward the same event and observe failure

Relevant log output

From forwarding CLI:

> # Subscribed to channel.ban via mock EventSub

> curl -X GET 'http://localhost:8080/eventsub/subscriptions' -H 'Client-Id: 4ofh8m0706jqpholgk00u3xvb4spct'
{"total":1,"total_cost":0,"max_total_cost":10,"pagination":{},"data":[{"id":"30ebc708-82b9-db08-3b74-6774cc8bee32","status":"enabled","type":"channel.ban","version":"1","created_at":"2024-03-12T18:18:56.7104022Z","cost":0,"condition":{"broadcaster_user_id":"57047445"},"transport":{"method":"websocket","session_id":"3eecdd64_c9e23329","connected_at":"2024-03-12T18:18:53.6964102Z"}}]}

> twitch event trigger channel.ban --transport=websocket
✔ Forwarded for use in mock EventSub WebSocket server
{"subscription":{"id":"ef467cce-4194-149c-dc0d-4137f41c267f","status":"enabled","type":"channel.ban","version":"1","condition":{"broadcaster_user_id":"65724368"},"transport":{"method":"websocket","session_id":"WebSocket-Server-Will-Set"},"created_at":"2024-03-12T18:19:54.2998115Z","cost":0},"event":{"banned_at":"2024-03-12T18:19:54.2998115Z","broadcaster_user_id":"65724368","broadcaster_user_login":"testBroadcaster","broadcaster_user_name":"testBroadcaster","ends_at":null,"is_permanent":true,"moderator_user_id":"73137767","moderator_user_login":"CLIModerator","moderator_user_name":"CLIModerator","reason":"This is a test event","user_id":"89311479","user_login":"testFromUser","user_name":"testFromUser"}}

> twitch event websocket reconnect
✔ Forwarded for use in mock EventSub WebSocket server

> # Reconnected WebSocket client to the URL the server provided

> curl -X GET 'http://localhost:8080/eventsub/subscriptions' -H 'Client-Id: 4ofh8m0706jqpholgk00u3xvb4spct'
{"total":1,"total_cost":0,"max_total_cost":10,"pagination":{},"data":[{"id":"30ebc708-82b9-db08-3b74-6774cc8bee32","status":"enabled","type":"channel.ban","version":"1","created_at":"2024-03-12T18:18:56.7104022Z","cost":0,"condition":{"broadcaster_user_id":"57047445"},"transport":{"method":"websocket","session_id":"06a89929_10f57612","connected_at":"2024-03-12T18:18:53.6964102Z"}}]}

> twitch event trigger channel.ban --transport=websocket
✗ EventSub WebSocket server failed to process event: [Error executing remote triggered EventSub: No clients with the subscribed to [channel.ban / 1]] Error executing remote triggered EventSub: No clients with the subscribed to [channel.ban / 1]
{"subscription":{"id":"825a89b8-05f8-8b65-70ce-444e76380867","status":"enabled","type":"channel.ban","version":"1","condition":{"broadcaster_user_id":"2754612"},"transport":{"method":"websocket","session_id":"WebSocket-Server-Will-Set"},"created_at":"2024-03-12T18:21:08.9709666Z","cost":0},"event":{"banned_at":"2024-03-12T18:21:08.9709666Z","broadcaster_user_id":"2754612","broadcaster_user_login":"testBroadcaster","broadcaster_user_name":"testBroadcaster","ends_at":null,"is_permanent":true,"moderator_user_id":"57421516","moderator_user_login":"CLIModerator","moderator_user_name":"CLIModerator","reason":"This is a test event","user_id":"28156716","user_login":"testFromUser","user_name":"testFromUser"}}

From server:

2024/03/12 11:18:35 Connect to the WebSocket server at: ws://127.0.0.1:8080/ws
2024/03/12 11:18:53 Client connected [c9e23329]
2024/03/12 11:18:53 [3eecdd64] Connections: (1) [ c9e23329 ]
2024/03/12 11:19:54 Sent [channel.ban / 1] to client [c9e23329]
2024/03/12 11:20:08 Initiating reconnect testing...
2024/03/12 11:20:08 Reconnect notices sent for server [3eecdd64]
2024/03/12 11:20:08 Will disconnect all existing clients in 30 seconds...
2024/03/12 11:20:19 read err [c9e23329]: websocket: close 1005 (no status)
2024/03/12 11:20:19 Disconnected client [c9e23329] with code [1000]
2024/03/12 11:20:19 [3eecdd64] Connections: (0) [  ]
2024/03/12 11:20:22 Client connected [10f57612]
2024/03/12 11:20:22 [06a89929] Connections: (1) [ 10f57612 ]
2024/03/12 11:20:38 All users disconnected from server [3eecdd64]
2024/03/12 11:20:38 Reconnect testing successful. Primary server is now [06a89929]
You may now execute reconnect testing again.
2024/03/12 11:21:08 Error executing remote triggered EventSub: No clients with the subscribed to [channel.ban / 1]
@Xemdo Xemdo added the bug Something isn't working label Mar 12, 2024
@Xemdo
Copy link
Contributor Author

Xemdo commented Mar 12, 2024

This is symptom of a larger issue: There should be 4 concepts in the mock WebSocket server:

  • WebSocket Server
  • WebSocket Server Manager
  • EventSub Manager
  • Gateway (to handle HTTP entry)

However, when I set this up I managed to put the EventSub Manager inside of the WebSocket server, which is incorrect because EventSub subscriptions are technically transport agnostic.

This should all be fixed in the future, but its more than the quick fix I want to put into place to fix this. For work on this tech debt, see #317.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant