Raptor123471 / DingoLingo

A Discord music bot written in Python with support for Youtube, SoundCloud, Spotify, Bandcamp, Twitter, and custom files.
GNU General Public License v3.0
280 stars 164 forks source link

Timeout on startup #96

Closed Nam0 closed 2 years ago

Nam0 commented 2 years ago

I was previously using the bot with no issues until I swapped the machine I'm using to run it. I've got all of the requirements installed and it times out. I was getting this error and then uninstalled and reinstalled everything

namo@namo-svr2:~/Desktop/DingoLingo$ python3.7 run.py
Starting Bot...
Joined NaCl-y Gamers
Startup Complete
Ignoring exception in command play:
Traceback (most recent call last):
  File "/home/nam0/.local/lib/python3.7/site-packages/discord/ext/commands/core.                                                                                                                                                             py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/nam0/Desktop/DingoLingo/musicbot/commands/music.py", line 27, in _                                                                                                                                                             play_song
    if await audiocontroller.uconnect(ctx) == False:
  File "/home/nam0/Desktop/DingoLingo/musicbot/audiocontroller.py", line 350, in                                                                                                                                                              uconnect
    await self.register_voice_channel(ctx.author.voice.channel)
  File "/home/nam0/Desktop/DingoLingo/musicbot/audiocontroller.py", line 47, in                                                                                                                                                              register_voice_channel
    await channel.connect(reconnect=True, timeout=None)
  File "/home/nam0/.local/lib/python3.7/site-packages/discord/abc.py", line 1277                                                                                                                                                             , in connect
    voice = cls(client, self)
  File "/home/nam0/.local/lib/python3.7/site-packages/discord/voice_client.py",                                                                                                                                                              line 199, in __init__
    raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/nam0/.local/lib/python3.7/site-packages/discord/ext/commands/bot.p                                                                                                                                                             y", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/nam0/.local/lib/python3.7/site-packages/discord/ext/commands/core.                                                                                                                                                             py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/nam0/.local/lib/python3.7/site-packages/discord/ext/commands/core.                                                                                                                                                             py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Run     

Pip list outdated from then.

namo@namo-svr2:~/Desktop/DingoLingo$ python3.7 -m pip list --outdated
Package             Version       Latest  Type
------------------- ------------- ------- -----
aiohttp             3.6.0         3.8.1   wheel
async-timeout       3.0.1         4.0.2   wheel
bcrypt              3.1.7         3.2.0   wheel
chardet             3.0.4         4.0.0   wheel
Click               7.0           8.0.4   wheel
colorama            0.4.3         0.4.4   wheel
cryptography        2.8           36.0.1  wheel
dbus-python         1.2.16        1.2.18  sdist
distro              1.4.0         1.7.0   wheel
distro-info         0.23ubuntu1   1.0     wheel
duplicity           0.8.12.0      0.8.22  sdist
entrypoints         0.3           0.4     wheel
fasteners           0.14.1        0.17.3  wheel
httplib2            0.14.0        0.20.4  wheel
keyring             18.0.1        23.5.0  wheel
launchpadlib        1.10.13       1.10.16 wheel
lazr.restfulclient  0.14.2        0.14.4  sdist
lazr.uri            1.0.3         1.0.6   sdist
Mako                1.1.0         1.2.0   wheel
MarkupSafe          1.1.0         2.1.0   wheel
monotonic           1.5           1.6     wheel
multidict           4.7.6         6.0.2   wheel
netifaces           0.10.4        0.11.0  wheel
oauthlib            3.1.0         3.2.0   wheel
paramiko            2.6.0         2.10.1  wheel
pexpect             4.6.0         4.8.0   wheel
Pillow              7.0.0         9.0.1   wheel
pip                 20.0.2        22.0.4  wheel
protobuf            3.6.1         3.19.4  wheel
pycairo             1.16.2        1.21.0  sdist
pycups              1.9.73        2.0.1   sdist
PyGObject           3.36.0        3.42.0  sdist
PyJWT               1.7.1         2.3.0   wheel
PyNaCl              1.3.0         1.5.0   wheel
python-dateutil     2.7.3         2.8.2   wheel
python-debian       0.1.36ubuntu1 0.1.43  wheel
pytz                2019.3        2021.3  wheel
pyxdg               0.26          0.27    wheel
PyYAML              5.3.1         6.0     wheel
reportlab           3.5.34        3.6.8   wheel
requests-unixsocket 0.2.0         0.3.0   wheel
SecretStorage       2.3.1         3.3.1   wheel
setuptools          45.2.0        60.9.3  wheel
simplejson          3.16.0        3.17.6  wheel
ssh-import-id       5.10          5.11    sdist
wadllib             1.3.3         1.3.6   sdist
wheel               0.34.2        0.37.1  wheel

Now when I try to start the bot it will sit blank for about 30 seconds then I receive this.

namo@namo-svr2:~/DingoLingo$ python3.7 run.py 
Traceback (most recent call last):
  File "run.py", line 84, in <module>
    bot.run(config.BOT_TOKEN, bot=True, reconnect=True)
  File "/home/namo/.local/lib/python3.7/site-packages/discord/client.py", line 723, in run
    return future.result()
  File "/home/namo/.local/lib/python3.7/site-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "/home/namo/.local/lib/python3.7/site-packages/discord/client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "/home/namo/.local/lib/python3.7/site-packages/discord/client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "/home/namo/.local/lib/python3.7/site-packages/discord/http.py", line 300, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/home/namo/.local/lib/python3.7/site-packages/discord/http.py", line 192, in request
    async with self.__session.request(method, url, **kwargs) as r:
  File "/home/namo/.local/lib/python3.7/site-packages/aiohttp/client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "/home/namo/.local/lib/python3.7/site-packages/aiohttp/client.py", line 619, in _request
    break
  File "/home/namo/.local/lib/python3.7/site-packages/aiohttp/helpers.py", line 656, in __exit__
    raise asyncio.TimeoutError from None
concurrent.futures._base.TimeoutError
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7fbcb56ce290>

Pip list output for the version's I have installed

namo@namo-svr2:~/DingoLingo/config$ python3.7 -m pip list
Package                Version
---------------------- --------------------
aiohttp                3.7.0
apturl                 0.5.2
async-timeout          3.0.1
asyncio                3.4.3
attrs                  21.4.0
bcrypt                 3.1.7
beautifulsoup4         4.10.0
blinker                1.4
Brlapi                 0.7.0
Brotli                 1.0.9
certifi                2019.11.28
chardet                3.0.4
charset-normalizer     2.0.12
Click                  7.0
colorama               0.4.3
command-not-found      0.3
cryptography           2.8
cupshelpers            1.0
dbus-python            1.2.16
defer                  1.0.6
discord.py             1.7.3
distro                 1.4.0
distro-info            0.23ubuntu1
duplicity              0.8.12.0
entrypoints            0.3
fasteners              0.14.1
future                 0.18.2
httplib2               0.14.0
idna                   2.8
keyring                18.0.1
language-selector      0.1
launchpadlib           1.10.13
lazr.restfulclient     0.14.2
lazr.uri               1.0.3
lockfile               0.12.2
louis                  3.12.0
macaroonbakery         1.3.1
Mako                   1.1.0
MarkupSafe             1.1.0
monotonic              1.5
multidict              6.0.2
mutagen                1.45.1
netifaces              0.10.4
oauthlib               3.1.0
olefile                0.46
paramiko               2.6.0
pbr                    5.8.1
pexpect                4.6.0
Pillow                 7.0.0
pip                    22.0.4
protobuf               3.6.1
py-cord                1.7.3
pycairo                1.16.2
pycryptodomex          3.14.1
pycups                 1.9.73
PyGObject              3.36.0
PyJWT                  1.7.1
pymacaroons            0.13.0
PyNaCl                 1.3.0
pyRFC3339              1.1
python-apt             2.0.0+ubuntu0.20.4.7
python-dateutil        2.7.3
python-debian          0.1.36ubuntu1
pytz                   2019.3
pyxdg                  0.26
PyYAML                 5.3.1
reportlab              3.5.34
requests               2.27.1
requests-unixsocket    0.2.0
SecretStorage          2.3.1
setuptools             60.9.3
simplejson             3.16.0
six                    1.16.0
soupsieve              2.3.1
spotipy                2.19.0
systemd-python         234
testresources          2.0.1
typing_extensions      4.1.1
ubuntu-advantage-tools 27.6
ubuntu-drivers-common  0.0.0
ufw                    0.36
unattended-upgrades    0.1
urllib3                1.26.8
usb-creator            0.3.7
wadllib                1.3.3
websockets             10.2
wheel                  0.37.1
xkit                   0.0.0
yarl                   1.7.2
yt-dlp                 2022.3.8.2

I'm not sure on what has changed from when I originally had the bot to now. Thank you for any input!

Nam0 commented 2 years ago

I'm not quite sure on what I changed to go from the timeout errors I was receiving to SSL errors but I fixed those by upgrading aiohttp from 3.6.0 to 3.8.0 and then I fixed my PyNacl issue by updating that to 1.5.0 despite it saying it's not compatible with some packages. It works fine for youtube, bandcamp, soundcloud but not spotify most likely due to an incompatibility with the spotipy package Here is a current package list

namo@namo-svr2:~/DingoLingo/musicbot$ python3.7 -m pip list
Package                Version
---------------------- --------------------
aiohttp                3.8.0
aiosignal              1.2.0
apturl                 0.5.2
async-timeout          4.0.2
asyncio                3.4.3
asynctest              0.13.0
attrs                  21.4.0
bcrypt                 3.1.7
beautifulsoup4         4.10.0
blinker                1.4
Brlapi                 0.7.0
Brotli                 1.0.9
certifi                2019.11.28
cffi                   1.15.0
chardet                3.0.4
charset-normalizer     2.0.12
Click                  7.0
colorama               0.4.3
command-not-found      0.3
cryptography           2.8
cupshelpers            1.0
dbus-python            1.2.16
defer                  1.0.6
discord.py             1.7.3
distro                 1.4.0
distro-info            0.23ubuntu1
duplicity              0.8.12.0
entrypoints            0.3
fasteners              0.14.1
frozenlist             1.3.0
future                 0.18.2
httplib2               0.14.0
idna                   2.8
keyring                18.0.1
language-selector      0.1
launchpadlib           1.10.13
lazr.restfulclient     0.14.2
lazr.uri               1.0.3
lockfile               0.12.2
louis                  3.12.0
macaroonbakery         1.3.1
Mako                   1.1.0
MarkupSafe             1.1.0
monotonic              1.5
multidict              6.0.2
mutagen                1.45.1
netifaces              0.10.4
oauthlib               3.1.0
olefile                0.46
paramiko               2.6.0
pbr                    5.8.1
pexpect                4.6.0
Pillow                 7.0.0
pip                    22.0.4
protobuf               3.6.1
py-cord                1.7.3
pycairo                1.16.2
pycparser              2.21
pycryptodomex          3.14.1
pycups                 1.9.73
PyGObject              3.36.0
PyJWT                  1.7.1
pymacaroons            0.13.0
PyNaCl                 1.5.0
pyRFC3339              1.1
python-apt             2.0.0+ubuntu0.20.4.7
python-dateutil        2.7.3
python-debian          0.1.36ubuntu1
pytz                   2019.3
pyxattr                0.6.1
pyxdg                  0.26
PyYAML                 5.3.1
reportlab              3.5.34
requests               2.27.1
requests-unixsocket    0.2.0
SecretStorage          2.3.1
setuptools             60.9.3
simplejson             3.16.0
six                    1.16.0
soupsieve              2.3.1
spotipy                2.19.0
systemd-python         234
testresources          2.0.1
typing_extensions      4.1.1
ubuntu-advantage-tools 27.6
ubuntu-drivers-common  0.0.0
ufw                    0.36
unattended-upgrades    0.1
urllib3                1.24.3
usb-creator            0.3.7
wadllib                1.3.3
websockets             10.2
wheel                  0.37.1
xkit                   0.0.0
yarl                   1.7.2
youtube-dl             2020.3.24
yt-dlp                 2022.3.8.2

I also updated openssl to 1.1.f running ssl.create_default_context().cert_store_stats() still returns ```{'x509': 0, 'crl': 0, 'x509_ca': 0}


All in all I'm not sure what did the trick but I hope this helps out someone!
Nam0 commented 2 years ago
Traceback (most recent call last):
  File "/home/namo/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 985, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  File "/usr/lib/python3.7/asyncio/base_events.py", line 989, in create_connection
    ssl_handshake_timeout=ssl_handshake_timeout)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 1017, in _create_connection_transport
    await waiter
  File "/usr/lib/python3.7/asyncio/sslproto.py", line 530, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "/usr/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata
    self._sslobj.do_handshake()
  File "/usr/lib/python3.7/ssl.py", line 774, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "run.py", line 84, in <module>
    bot.run(config.BOT_TOKEN, bot=True, reconnect=True)
  File "/home/namo/.local/lib/python3.7/site-packages/discord/client.py", line 723, in run
    return future.result()
  File "/home/namo/.local/lib/python3.7/site-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "/home/namo/.local/lib/python3.7/site-packages/discord/client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "/home/namo/.local/lib/python3.7/site-packages/discord/client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "/home/namo/.local/lib/python3.7/site-packages/discord/http.py", line 300, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/home/namo/.local/lib/python3.7/site-packages/discord/http.py", line 192, in request
    async with self.__session.request(method, url, **kwargs) as r:
  File "/home/namo/.local/lib/python3.7/site-packages/aiohttp/client.py", line 1140, in __aenter__
    self._resp = await self._coro
  File "/home/namo/.local/lib/python3.7/site-packages/aiohttp/client.py", line 536, in _request
    req, traces=traces, timeout=real_timeout
  File "/home/namo/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 543, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/namo/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 906, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/home/namo/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 1205, in _create_direct_connection
    raise last_exc
  File "/home/namo/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 1186, in _create_direct_connection
    client_error=client_error,
  File "/home/namo/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 987, in _wrap_create_connection
    raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)')]
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f30d7a58b10>

Got the SSL errors again, after rebooting my machine, no updates where done to pip packages or any changes made to the machine that could've affected this. Tried a bunch of stuff then swapped to Python3.8 as Discord.py says it supports 3.8+ ran (installed per-requisites first of course)


sudo update-ca-certificates --fresh
export SSL_CERT_DIR=/etc/ssl/certs``` and that did the trick now everything is up and running perfectly.