DiscordPHP: Invalid session in 4.0.4

When looking at the logs I noticed the bot is having trouble connecting at its first attempt. This happens with all initiations. I haven’t seen this happen on the master code. But while looking through recent changes in develop I couldn’t find anything that might cause this behaviour.

I’m happy to submit a PR with some guidance what to look for.

[2020-08-27 11:53:06] DiscordPHP.INFO: gateway retrieved and set {"gateway":"wss://gateway.discord.gg/?v=6&encoding=json"} []
[2020-08-27 11:53:06] DiscordPHP.INFO: starting connection to websocket {"gateway":"wss://gateway.discord.gg/?v=6&encoding=json"} []
[2020-08-27 11:53:06] DiscordPHP.INFO: websocket connection has been created [] []
[2020-08-27 11:53:06] DiscordPHP.INFO: received hello [] []
[2020-08-27 11:53:06] DiscordPHP.INFO: identifying {"payload":{"op":2,"d":{"token":"*****","properties":{"$os":"Linux","$browser":"DiscordBot (https://github.com/teamreflex/DiscordPHP, v4.0.4)","$device":"DiscordBot (https://github.com/teamreflex/DiscordPHP, v4.0.4)","$referrer":"https://github.com/teamreflex/DiscordPHP","$referring_domain":"https://github.com/teamreflex/DiscordPHP"},"compress":true}}} []
[2020-08-27 11:53:06] DiscordPHP.DEBUG: sending heartbeat {"seq":null} []
[2020-08-27 11:53:06] DiscordPHP.INFO: heartbeat timer initilized {"interval":41250} []
[2020-08-27 11:53:06] DiscordPHP.DEBUG: received heartbeat ack {"response_time":123.68893623352051} []
[2020-08-27 11:53:06] DiscordPHP.DEBUG: ready packet received [] []
[2020-08-27 11:53:06] DiscordPHP.DEBUG: discord trace received {"trace":["[\"gateway-prd-main-kbkz\",{\"micros\":128043,\"calls\":[\"discord-sessions-prd-2-4\",{\"micros\":127047,\"calls\":[\"start_session\",{\"micros\":103440,\"calls\":[\"api-prd-main-d3v9\",{\"micros\":99690,\"calls\":[\"get_user\",{\"micros\":2951},\"add_authorized_ip\",{\"micros\":6680},\"get_guilds\",{\"micros\":11334},\"coros_wait\",{\"micros\":2}]}]},\"guilds_connect\",{\"micros\":1,\"calls\":[]},\"presence_connect\",{\"micros\":6673,\"calls\":[]}]}]}]"]} []
[2020-08-27 11:53:06] DiscordPHP.DEBUG: client created and session id stored {"session_id":"*****","user":{"id":"668570338770288672","username":"GSA-LOCAL","avatar":null,"discriminator":"4511","bot":null}} []
Total domains: 1
Total tribes: 0
[2020-08-27 11:53:08] DiscordPHP.INFO: gateway retrieved and set {"gateway":"wss://gateway.discord.gg/?v=6&encoding=json"} []
[2020-08-27 11:53:08] DiscordPHP.INFO: starting connection to websocket {"gateway":"wss://gateway.discord.gg/?v=6&encoding=json"} []
[2020-08-27 11:53:08] DiscordPHP.INFO: websocket connection has been created [] []
[2020-08-27 11:53:08] DiscordPHP.INFO: received hello [] []
[2020-08-27 11:53:08] DiscordPHP.INFO: identifying {"payload":{"op":2,"d":{"token":"*****","properties":{"$os":"Linux","$browser":"DiscordBot (https://github.com/teamreflex/DiscordPHP, v4.0.4)","$device":"DiscordBot (https://github.com/teamreflex/DiscordPHP, v4.0.4)","$referrer":"https://github.com/teamreflex/DiscordPHP","$referring_domain":"https://github.com/teamreflex/DiscordPHP"},"compress":true}}} []
[2020-08-27 11:53:08] DiscordPHP.DEBUG: sending heartbeat {"seq":null} []
[2020-08-27 11:53:08] DiscordPHP.INFO: heartbeat timer initilized {"interval":41250} []
[2020-08-27 11:53:08] DiscordPHP.DEBUG: received heartbeat ack {"response_time":125.73695182800293} []
[2020-08-27 11:53:11] DiscordPHP.WARNING: invalid session, re-identifying [] []
[2020-08-27 11:53:11] DiscordPHP.INFO: identifying {"payload":{"op":2,"d":{"token":"*****","properties":{"$os":"Linux","$browser":"DiscordBot (https://github.com/teamreflex/DiscordPHP, v4.0.4)","$device":"DiscordBot (https://github.com/teamreflex/DiscordPHP, v4.0.4)","$referrer":"https://github.com/teamreflex/DiscordPHP","$referring_domain":"https://github.com/teamreflex/DiscordPHP"},"compress":true}}} []
[2020-08-27 11:53:11] DiscordPHP.DEBUG: ready packet received [] []
[2020-08-27 11:53:11] DiscordPHP.DEBUG: discord trace received {"trace":["[\"gateway-prd-main-89tj\",{\"micros\":47750,\"calls\":[\"discord-sessions-prd-2-1\",{\"micros\":46909,\"calls\":[\"start_session\",{\"micros\":43517,\"calls\":[\"api-prd-main-lq36\",{\"micros\":40902,\"calls\":[\"get_user\",{\"micros\":2602},\"add_authorized_ip\",{\"micros\":1435},\"get_guilds\",{\"micros\":1491},\"coros_wait\",{\"micros\":1}]}]},\"guilds_connect\",{\"micros\":1,\"calls\":[]},\"presence_connect\",{\"micros\":2460,\"calls\":[]}]}]}]"]} []
[2020-08-27 11:53:11] DiscordPHP.DEBUG: client created and session id stored {"session_id":"*****","user":{"id":"668570338770288672","username":"GSA-LOCAL","avatar":null,"discriminator":"4511","bot":null}} []
[2020-08-27 11:53:11] DiscordPHP.INFO: did not parse private channels [] []
[2020-08-27 11:53:11] DiscordPHP.INFO: stored guilds {"count":0,"unavailable":2} []
[2020-08-27 11:53:11] DiscordPHP.DEBUG: guild available {"guild":"668565844833599505"} []
[2020-08-27 11:53:11] DiscordPHP.DEBUG: guild available {"guild":"668569080260984863"} []
[2020-08-27 11:53:11] DiscordPHP.INFO: all guilds are now available {"count":2} []
[2020-08-27 11:53:11] DiscordPHP.INFO: loadAllMembers option is disabled, not setting chunking up [] []
[2020-08-27 11:53:11] DiscordPHP.INFO: client is ready [] []

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

Could you try the cache branch? I’ve removed some of the caching features as they didn’t work and just confused people. I’ve optimised the guild create and guild member chunks (74b0198b44e69e3dcf99e95c1daa1bb7ff2ae9a2). Also removed the Laravel dependency from the Collection class, but along with that goes the features (75af83942348013232b4b9073d27953ea6dff68b).

I will look at rewriting the collection class most likely. Possibly instead of extending the Laravel Collection class, will have a collection in the background and the new Collection will pass calls to the laravel collection.

I do have some retry options added. I’m gonna do some further digging to make sure its not something else. I’ll update here when I have more info. Thanks so far!