Closed qrawless closed 2 years ago
Opcode 7 is Discord telling DiscordPHP to reconnect to the gateway. This is the correct behavior.
Update per Discord conversation: The program seems to end before the Websocket can be reconnected/queued reconnect does not get executed.
all transactions are being queued. but it never happens. I think there is the same problem with reconnection. Is there a way to kill when the connection is broken?
(as a workaround i kill the app every 10 minutes..)
Can you post the output of composer show
?
Linked to #533
discord-php/http v8.1.1 Handles HTTP requests to D... evenement/evenement v3.0.1 Événement is a very simp... guzzlehttp/psr7 1.8.2 PSR-7 message implementati... mollie/polyfill-libsodium v1.1.1 A polyfill package to tran... monolog/monolog 2.2.0 Sends your logs to files, ... nesbot/carbon 2.48.0 An API extension for DateT... phpfastcache/phpfastcache 8.0.5 PHP Abstract Cache Class -... psr/cache 1.0.1 Common interface for cachi... psr/http-message 1.0.1 Common interface for HTTP ... psr/log 1.1.4 Common interface for loggi... psr/simple-cache 1.0.1 Common interfaces for simp... qrawless/lol-api dev-master 5aa61fd League of legends PHP API. ralouphie/getallheaders 3.0.3 A polyfill for getallheaders. ratchet/pawl v0.3.5 Asynchronous WebSocket client ratchet/rfc6455 v0.3 RFC6455 WebSocket protocol... react/cache v1.1.1 Async, Promise-based cache... react/child-process v0.6.2 Event-driven library for e... react/datagram v1.5.0 Event-driven UDP datagram ... react/dns v1.5.0 Async DNS resolver for Rea... react/event-loop v1.1.1 ReactPHP's core reactor ev... react/http v1.3.0 Event-driven, streaming HT... react/partial v3.0.0 Partial function application. react/promise v2.8.0 A lightweight implementati... react/promise-stream v1.2.0 The missing link between P... react/promise-timer v1.6.0 A trivial implementation o... react/socket v1.6.0 Async, streaming plaintext... react/stream v1.1.1 Event-driven readable and ... ringcentral/psr7 1.3.0 PSR-7 message implementation symfony/deprecation-contracts v2.4.0 A generic function and con... symfony/options-resolver v5.2.4 Provides an improved repla... symfony/polyfill-mbstring v1.22.1 Symfony polyfill for the M... symfony/polyfill-php73 v1.22.1 Symfony polyfill backporti... symfony/polyfill-php80 v1.22.1 Symfony polyfill backporti... symfony/translation v5.2.9 Provides tools to internat... symfony/translation-contracts v2.4.0 Generic abstractions relat... team-reflex/discord-php dev-master 2bf2e4c An unofficial API to inter... trafficcophp/bytebuffer v0.3 Node.js inspired byte stre...
I'll try to have a look this weekend, the only time I've seen others having this issue is when they have a suspicious connection, could you elaborate more on your hosting situation?
I have this problem from time to time, it is most likely related to network issues (or the reconnection itself).
Checking my logs, I could see this pattern:
After receiving an opcode 7
[2022-01-03T03:45:01.369563-03:00] BOT_LOGS.WARNING: received opcode 7 for reconnect [] []
The reconnection is started (as expected)
[2022-01-03T03:45:01.370838-03:00] BOT_LOGS.WARNING: websocket closed {"op":4000,"reason":"gateway redirecting - opcode 7"} []
[2022-01-03T03:45:01.371740-03:00] BOT_LOGS.WARNING: reconnecting in 2 seconds [] []
[2022-01-03T03:45:03.372965-03:00] BOT_LOGS.INFO: starting reconnect {"reconnect_count":3} []
[2022-01-03T03:45:03.374938-03:00] BOT_LOGS.DEBUG: BUCKET getgateway/bot queued REQ GET gateway/bot [] []
If an error (network) occurs in this reconnection, the attempt goes to fallback in the default
[2022-01-03T03:45:13.388322-03:00] BOT_LOGS.WARNING: REQ GET gateway/bot failed: Connection to discord.com:443 failed during DNS lookup: DNS query for discord.com (A) timed out. DNS query for discord.com (A) timed out [] []
[2022-01-03T03:45:13.388790-03:00] BOT_LOGS.WARNING: could not retrieve gateway, using default [] []
Try again, but it fails, then wait 5s for a new attempt
[2022-01-03T03:45:13.389067-03:00] BOT_LOGS.INFO: gateway retrieved and set {"gateway":"wss://gateway.discord.gg/?v=9&encoding=json","session":{"total":1000,"remaining":1000,"reset_after":0,"max_concurrency":1}} []
[2022-01-03T03:45:13.389396-03:00] BOT_LOGS.INFO: starting connection to websocket {"gateway":"wss://gateway.discord.gg/?v=9&encoding=json"} []
[2022-01-03T03:45:23.393387-03:00] BOT_LOGS.ERROR: failed to connect to websocket, retry in 5 seconds {"e":"Connection to gateway.discord.gg:443 failed during DNS lookup: DNS query for gateway.discord.gg (A) timed out. DNS query for gateway.discord.gg (A) timed out"} []
This last request is queued but never executed
[2022-01-03T03:45:28.394636-03:00] BOT_LOGS.DEBUG: BUCKET getgateway/bot queued REQ GET gateway/bot [] []
An interesting thing to note, other non-websoocket-related requests (scheduled execution) are still working correctly and being processed (queued and executed) normally.
Example: editing messages
[2022-01-03T03:47:25.900745-03:00] BOT_LOGS.INFO: ATT_EVENTOS ["atualizarCardFuturo 177"] []
[2022-01-03T03:47:25.923234-03:00] BOT_LOGS.DEBUG: BUCKET patchchannels/885688612530843648/messages/:message_id queued REQ PATCH channels/885688612530843648/messages/927408840318779454 [] []
[2022-01-03T03:47:26.223486-03:00] BOT_LOGS.DEBUG: REQ PATCH channels/885688612530843648/messages/927408840318779454 successful [] []
[2022-01-03T03:47:26.224884-03:00] BOT_LOGS.DEBUG: http not checking {"waiting":1,"empty":true} []
However everything related to websocket (clearly) stops working.. Presence, interactions...
Environment
PHP Version:
DiscordPHP Version:
I have some logs that show this behavior on a recurring basis, let me know if you want full access.
This might have been fixed with discord-php/http version 9.0.10. Please do composer update
and let us know here.
no reply in 21 days
Environment
The bot shuts down on its own.
Console: