Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working great for a ffew hours or minutes until I got this error #10

Closed
asdfawjbhsdhbasjindh opened this issue Sep 20, 2022 · 6 comments

Comments

@asdfawjbhsdhbasjindh
Copy link

the bot was working great for the past few days but when I run it now it gives me this error

Ignoring exception in command farm:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 1042, in validate_conn
conn.connect()
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl
.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl
.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 513, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1071, in _create
self.do_handshake()
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1342, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen(
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='discord.com', port=443): Max retries exceeded with url: /api/v9/interactions (Caused by SSLError(SSLError(1, '[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Dank Memer Autofarm\bot.py", line 19, in farm
Hunt(channel_id, guild_id)
File "C:\Dank Memer Autofarm\slashCommands.py", line 176, in Hunt
req = requests.post('https://discord.com/api/v9/interactions', headers={"authorization": token}, json=payload)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='discord.com', port=443): Max retries exceeded with url: /api/v9/interactions (Caused by SSLError(SSLError(1, '[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)')))

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

Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\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: SSLError: HTTPSConnectionPool(host='discord.com', port=443): Max retries exceeded with url: /api/v9/interactions (Caused by SSLError(SSLError(1, '[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)')))

@asdfawjbhsdhbasjindh
Copy link
Author

it basically works from 2-8 hours and then gives me that error

@moleium
Copy link
Owner

moleium commented Sep 21, 2022

In the first error shown, you can see sslv3 alert handshake failure

then the last error, same thing, but it triggered Max retries exceeded with URL too

because it couldn't fix the handshake failure.

SSL Handshake: used to authenticate data transfers between servers and external systems such as browsers.
I also noticed a kind of reconnection after some hours passed but no SSL error showed. My conclusion that is your SSL Handshake failure was caused by external parties, not from the bot itself, maybe your connection, etc.

You can disable requests verification to resolve it but that wouldn't be secure. by passing the parameterverify=False in SlashCommands.py in every request. use Search & Replace. It would do it automatically without adding it manually.

Replace every line that has this:

req = requests.post('https://discord.com/api/v9/interactions', headers={"authorization": token}, json=payload)

With:

req = requests.post('https://discord.com/api/v9/interactions', verify=False , headers={"authorization": token}, json=payload)

And add those two lines in init.py or bot.py. It doesn't matter, but they should be added to the top lines.

import urllib3
urllib3.disable_warnings()

@asdfawjbhsdhbasjindh
Copy link
Author

asdfawjbhsdhbasjindh commented Sep 21, 2022

I want to ask, does a VPN
affect this error?

@asdfawjbhsdhbasjindh
Copy link
Author

also the reconnection was me starting the bot again

@moleium
Copy link
Owner

moleium commented Sep 21, 2022

VPN does affect the connection, especially with SSL handshake failures.

And i meant I did experience some reconnections after some hours passes. but no SSL handhake failure happened

@asdfawjbhsdhbasjindh
Copy link
Author

ok that makes sense, thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants