DiscordKit icon indicating copy to clipboard operation
DiscordKit copied to clipboard

Unexpected Discord Gateway Disconnection

Open libewa opened this issue 2 years ago • 3 comments

2023-09-03T18:19:06+0200 info RobustWebSocket : version=10 ws=wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream [DiscordKitCore] [CONNECT]
2023-09-03T18:19:06+0200 debug RobustWebSocket : reason=Hello payload received [DiscordKitCore] Invalidating conn timeout
2023-09-03T18:19:06+0200 info RobustWebSocket : heartbeat_interval=41250 [DiscordKitCore] [HELLO]
2023-09-03T18:19:06+0200 debug RobustWebSocket : interval=41.25 [DiscordKitCore] Start heartbeating
2023-09-03T18:19:06+0200 info RobustWebSocket : intents=Optional(DiscordKitCore.Intents(rawValue: 1146621)) [DiscordKitCore] [IDENTIFY]
2023-09-03T18:19:06+0200 trace RobustWebSocket : data=nil opcode=identify seq=-1 [DiscordKitCore] Outgoing Payload
2023-09-03T18:19:06+0200 info RobustWebSocket : session=81fcfab4f5f71a93df4ed8aee4442226 [DiscordKitCore] [READY]
2023-09-03T18:19:06+0200 info Client : application.id=1147885099979919514 user.id=1147885099979919514 [DiscordKitBot] Bot client ready
Registering interactions...
2023-09-03T18:19:06+0200 trace DiscordREST : method=put path=applications/1147885099979919514/guilds/840575490238840843/commands [DiscordKitCore] Making request
Registered interactions!
Successfully logged in as swifttest#1500!
2023-09-03T18:19:41+0200 debug RobustWebSocket : [DiscordKitCore] [HEARTBEAT] Sending heartbeat
2023-09-03T18:19:41+0200 trace RobustWebSocket : data=Optional(DiscordKitCore.GatewayHeartbeat(seq: Optional(1))) opcode=heartbeat seq=1 [DiscordKitCore] Outgoing Payload
2023-09-03T18:19:41+0200 error RobustWebSocket : error=disconnected [DiscordKitCore] Receive error
2023-09-03T18:19:41+0200 warning RobustWebSocket : [DiscordKitCore] Forcibly closing connection
2023-09-03T18:19:51+0200 warning RobustWebSocket : reason=socket timed out [DiscordKitCore] [HEARTBEAT] Force-closing connection
2023-09-03T18:19:51+0200 warning RobustWebSocket : [DiscordKitCore] Forcibly closing connection

libewa avatar Sep 03 '23 16:09 libewa

From logs, it looks like something out of DiscordKit's control is causing the WebSocket connection to the Discord Gateway to be extremely unstable, to the point that heartbeats can't be sent successfully. Are you on a stable network connection, and sure that any proxies/VPNs are either disabled or stable enough for such a connection?

cryptoAlgorithm avatar Sep 25 '23 10:09 cryptoAlgorithm

I don't know if it is related to this issue, but I have a similar one.

2023-12-24T09:48:20+0100 info RobustWebSocket : version=10 ws=wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream [DiscordKitCore] [CONNECT] 2023-12-24T09:48:20+0100 debug RobustWebSocket : reason=connection is reachable [DiscordKitCore] Reset backoff 2023-12-24T09:48:20+0100 warning RobustWebSocket : [DiscordKitCore] Reconnection in progress, not reconnecting 2023-12-24T09:48:20+0100 info RobustWebSocket : [DiscordKitCore] [CONNECTED] 2023-12-24T09:48:20+0100 trace DecompressionEngine : decompressed.count=124 original.count=115 [DiscordKitCore] Decompressed data 2023-12-24T09:48:20+0100 debug RobustWebSocket : reason=Hello payload received [DiscordKitCore] Invalidating conn timeout 2023-12-24T09:48:20+0100 info RobustWebSocket : heartbeat_interval=41250 [DiscordKitCore] [HELLO] 2023-12-24T09:48:20+0100 debug RobustWebSocket : interval=41.25 [DiscordKitCore] Start heartbeating 2023-12-24T09:48:20+0100 info RobustWebSocket : intents=Optional(DiscordKitCore.Intents(rawValue: 1146621)) [DiscordKitCore] [IDENTIFY] 2023-12-24T09:48:20+0100 trace RobustWebSocket : data=nil opcode=identify seq=-1 [DiscordKitCore] Outgoing Payload 2023-12-24T09:48:20+0100 error RobustWebSocket : [DiscordKitCore] Gateway closed with fatal close code! Cannot reconnect 2023-12-24T09:48:20+0100 error RobustWebSocket : [DiscordKitCore] [WS CLOSED] closed with error: no error description 2023-12-24T09:48:20+0100 error RobustWebSocket : error=Error Domain=NSPOSIXErrorDomain Code=57 "Socket is not connected" UserInfo={NSErrorFailingURLStringKey=wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream, NSErrorFailingURLKey=wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream} [DiscordKitCore] Receive error 2023-12-24T09:48:20+0100 warning RobustWebSocket : [DiscordKitCore] Forcibly closing connection 2023-12-24T09:48:20+0100 warning RobustWebSocket : [DiscordKitCore] [WS CLOSED] closeCode: 4004

Already tried to change connection, and checked for proxies/vpns disabled

IV0000 avatar Dec 24 '23 08:12 IV0000

@IV0000 Your issue doesn't appear to be an issue with DiscordKit. The close code of 4004 as seen in the logs:

warning RobustWebSocket : [DiscordKitCore] [WS CLOSED] closeCode: 4004

suggests the connection failure was due to an invalid token or otherwise incorrect credentials.

cryptoAlgorithm avatar Jan 14 '24 08:01 cryptoAlgorithm