Pycord-Development/pycord

Constant Shard Reconnection and ConnectionClosed Errors with AutoShardedBot

MrMetacomCode opened this issue · 1 comments

Summary

I'm using commands.AutoShardedBot and I get these error messages periodically. Nothing in the error is my code and the only thing I have done to shard the bot is to change commands.Bot to commands.AutoShardedBot as seen below in the minimal reproducible code.

2024-04-17 22:56:21,545:ERROR:discord.shard: Attempting a reconnect for shard ID 1 in 0.76s
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/discord/shard.py", line 180, in worker
    await self.ws.poll_event()
  File "/usr/local/lib/python3.10/site-packages/discord/gateway.py", line 632, in poll_event
    raise ConnectionClosed(
discord.errors.ConnectionClosed: Shard ID 1 WebSocket closed with 1000
2024-04-17 23:14:59,106:ERROR:discord.shard: Attempting a reconnect for shard ID 2 in 0.67s
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/discord/shard.py", line 180, in worker
    await self.ws.poll_event()
  File "/usr/local/lib/python3.10/site-packages/discord/gateway.py", line 632, in poll_event
    raise ConnectionClosed(
discord.errors.ConnectionClosed: Shard ID 2 WebSocket closed with 1000

Reproduction Steps

Start a commands.AutoShardedBot instance and let it run.

Minimal Reproducible Code

import discord
from discord import Intents
from discord.ext import commands

intents = Intents(guild_messages=True, guilds=True, voice_states=True, messages=True, message_content=True, members=True,
                  reactions=True, auto_moderation_execution=True)
bot = commands.AutoShardedBot(intents=intents)

TOKEN = 123456
bot.run(TOKEN)

Expected Results

To not have constant shard reconnection/closed connection errors.

Actual Results

I'm getting the errors shown.

Intents

Shown in minimum reproducible code answer.

System Information

Docker Compose Container on Ubuntu Server
Python 3.10
Pip Packages:

APScheduler==3.9.1
git+https://github.com/Pycord-Development/pycord.git
GitPython==3.1.42
PyYAML==6.0.1
python-dateutil==2.8.2
aiohttp==3.9.3
rsa==4.9

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

I was unable to reproduce this