TwitchDropsMiner
TwitchDropsMiner copied to clipboard
Cannot connect to Twitch
I use vds amazon ec2 free tier, (Windows Server 2022) with the help of browser authorization opens and tweetch site works, but with the help of the program writes that can not connect, what is the problem and how can it be fixed?
You need to enter the proxy address on the settings page, usually in the format http://127.0.0.1:port number
I have same problem (Win10 pro 64bit).
I found the solution to the problem, it was in SSL certificates, for some reason aiohttp could not find and use them, in the file twitch.py on line 662 change:
this:
connector = aiohttp.TCPConnector(limit=50)
to this:
connector = aiohttp.TCPConnector(verify_ssl=False, limit=50)
brother where is the twitch.py
brother where is the twitch.py
Do not use compiled version, download github source, and run it from python manual.
If you know how to install can you write dc dc_nick: time_thief.
Do you know where the source codes are?
Big green button on the home page:
Then either download zip
or grab the URL to use git clone <<Repo>>
(Just click the link I provided for now)
@CDeLeon94 There is no exe file in the dist folder
I found the solution to the problem, it was in SSL certificates, for some reason aiohttp could not find and use them, in the file twitch.py on line 662 change:
this:
connector = aiohttp.TCPConnector(limit=50)
to this:
connector = aiohttp.TCPConnector(verify_ssl=False, limit=50)
It works, thanks.
verify_ssl=False
is as good as solution to the problem here, as opening a window by breaking the glass. Read - it's not good.
The SSL verification error is masked by the request retry logic. To see it, one would need to disable the exception handling on requests, here: https://github.com/DevilXD/TwitchDropsMiner/blob/e5f4ea1261fb15aab9e18edb950f8b1a046c7dd7/twitch.py#L1505
Changing this to an unrelated exception, like except AssertionError:
will let the SSL error be printed out to the output window. Only with that traceback, I may be able to figure out what's wrong here. Without it, not so much.
Changing this to an unrelated exception, like
except AssertionError:
will let the SSL error be printed out to the output window. Only with that traceback, I may be able to figure out what's wrong here. Without it, not so much.
12:49:30: Fatal error encountered: 12:49:30: 12:49:30: Traceback (most recent call last): 12:49:30: File "aiohttp\connector.py", line 992, in _wrap_create_connection 12:49:30: File "asyncio\base_events.py", line 1146, in create_connection 12:49:30: File "asyncio\base_events.py", line 1179, in _create_connection_transport 12:49:30: File "asyncio\sslproto.py", line 575, in _on_handshake_complete 12:49:30: File "asyncio\sslproto.py", line 557, in _do_handshake 12:49:30: File "ssl.py", line 917, in do_handshake 12:49:30: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000) 12:49:30: 12:49:30: The above exception was the direct cause of the following exception: 12:49:30: 12:49:30: Traceback (most recent call last): 12:49:30: File "main.py", line 158, in main 12:49:30: File "twitch.py", line 764, in run 12:49:30: File "twitch.py", line 783, in _run 12:49:30: File "twitch.py", line 1469, in get_auth 12:49:30: File "twitch.py", line 515, in validate 12:49:30: File "twitch.py", line 524, in _validate 12:49:30: File "contextlib.py", line 210, in aenter 12:49:30: File "twitch.py", line 1494, in request 12:49:30: File "gui.py", line 2050, in coro_unless_closed 12:49:30: File "aiohttp\client.py", line 1174, in throw 12:49:30: File "aiohttp\client.py", line 574, in _request 12:49:30: File "aiohttp\connector.py", line 544, in connect 12:49:30: File "aiohttp\connector.py", line 911, in _create_connection 12:49:30: File "aiohttp\connector.py", line 1235, in _create_direct_connection 12:49:30: File "aiohttp\connector.py", line 1204, in _create_direct_connection 12:49:30: File "aiohttp\connector.py", line 994, in _wrap_create_connection 12:49:30: aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host m.twitch.tv:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)')] 12:49:30: 12:49:30: Exiting... 12:49:30: 12:49:30: Application Terminated. 12:49:30: Close the window to exit the application.
unable to get local issuer certificate
https://www.howtouselinux.com/post/exploring-unable-to-get-local-issuer-certificate
In other words, this is an issue with your machine, mostly. Here's some more resources on this topic:
https://github.com/aio-libs/aiohttp/issues/7287 https://github.com/aio-libs/aiohttp/issues/5375
Based on this information, it seems like something went wrong when you were installing Python. Reinstalling it may solve the problem. Alternatively, one can perform a disk error check / system integrity verification, via chkdsk
or a tool I made for this same purpose.
I have the same issue, same working conditions (amazon ec2 free tier, Windows Server 2022)
Just got the same error on Windows 11.. yesterday it was working fine. Today, I get the following
11:33:56: Cannot connect to Twitch, retrying in 30 seconds... 11:34:31: Cannot connect to Twitch, retrying in 60 seconds... 11:34:38: Earned points for watching: 10, total: 261263 11:34:38: Claimed bonus points: 50 11:34:39: Earned points for watching: 50, total: 261313 11:35:36: Cannot connect to Twitch, retrying in 141 seconds... 11:38:01: Cannot connect to Twitch, retrying in 180 seconds...
Even tried a fresh copy of 16.dev.6e0b461
I'm really not sure what else to say here. This is an issue related to your operating system, not the miner. Details of the SSL error and what to do with it can be found here: https://github.com/DevilXD/TwitchDropsMiner/issues/386#issuecomment-1854345004
You can verify that's the error you're running into, by disabling request error handling via these instructions: https://github.com/DevilXD/TwitchDropsMiner/issues/386#issuecomment-1852855472
I'll probably make it so that this particular error is allowed to "bubble out", while other ones will cause the usual retry loop. That'll make more sense in the long run.
Thanks for the reply and for your continued work on the project. It seems to be working fine now.. I've made no changes to my system in the past few days. Must have been related to some sort of outage.
Just got the same error on Windows 11.. yesterday it was working fine. Today, I get the following
11:33:56: Cannot connect to Twitch, retrying in 30 seconds... 11:34:31: Cannot connect to Twitch, retrying in 60 seconds... 11:34:38: Earned points for watching: 10, total: 261263 11:34:38: Claimed bonus points: 50 11:34:39: Earned points for watching: 50, total: 261313 11:35:36: Cannot connect to Twitch, retrying in 141 seconds... 11:38:01: Cannot connect to Twitch, retrying in 180 seconds...
Even tried a fresh copy of 16.dev.6e0b461
i'm facing the same issue, I tried this on Windows 11 (Desktop) and Raspberry Pi 5 (Pi OS)
FYI
By using the latest version of master it works now on my VM without doing the change mentioned in https://github.com/DevilXD/TwitchDropsMiner/issues/386#issuecomment-1851896426
Yes, I pushed out that commit to discourage disabling SSL as a "solution", per discussion under #415. Disabling SSL is not a safe solution by any means. I'd rather have an additional dependency that disable all web security measures.
I just started getting this error, out of nowhere. Twitch on the browser works just fine.
After applying the suggestion from https://github.com/DevilXD/TwitchDropsMiner/issues/386#issuecomment-1852855472 to figure out what the exception is, I always get this one (even after multiple app restarts and token renewals):
Click me to expand
17:46:55: Logging level: CALL
17:46:56: INFO: Checking login
17:46:56: INFO: Restoring session from cookie
17:46:57: INFO: Login successful, user ID: XXXXXX
17:46:57: INFO: Websocket[0] connecting...
17:46:58: INFO: Websocket[0] connected.
17:47:05: Fatal error encountered:
17:47:05:
17:47:05: Traceback (most recent call last):
17:47:05: File "/home/gui/dev/TwitchDropsMiner/env/lib/python3.11/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
17:47:05: return await self._loop.create_connection(*args, **kwargs)
17:47:05: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17:47:05: File "/usr/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
17:47:05: sock = await self._connect_sock(
17:47:05: ^^^^^^^^^^^^^^^^^^^^^^^^^
17:47:05: File "/usr/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
17:47:05: await self.sock_connect(sock, address)
17:47:05: File "/usr/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
17:47:05: return await fut
17:47:05: ^^^^^^^^^
17:47:05: asyncio.exceptions.CancelledError
17:47:05:
17:47:05: The above exception was the direct cause of the following exception:
17:47:05:
17:47:05: Traceback (most recent call last):
17:47:05: File "/home/gui/dev/TwitchDropsMiner/env/lib/python3.11/site-packages/aiohttp/client.py", line 574, in _request
17:47:05: conn = await self._connector.connect(
17:47:05: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17:47:05: File "/home/gui/dev/TwitchDropsMiner/env/lib/python3.11/site-packages/aiohttp/connector.py", line 544, in connect
17:47:05: proto = await self._create_connection(req, traces, timeout)
17:47:05: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17:47:05: File "/home/gui/dev/TwitchDropsMiner/env/lib/python3.11/site-packages/aiohttp/connector.py", line 911, in _create_connection
17:47:05: _, proto = await self._create_direct_connection(req, traces, timeout)
17:47:05: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17:47:05: File "/home/gui/dev/TwitchDropsMiner/env/lib/python3.11/site-packages/aiohttp/connector.py", line 1204, in _create_direct_connection
17:47:05: transp, proto = await self._wrap_create_connection(
17:47:05: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17:47:05: File "/home/gui/dev/TwitchDropsMiner/env/lib/python3.11/site-packages/aiohttp/connector.py", line 989, in _wrap_create_connection
17:47:05: async with ceil_timeout(
17:47:05: File "/usr/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
17:47:05: raise TimeoutError from exc_val
17:47:05: TimeoutError
17:47:05:
17:47:05: The above exception was the direct cause of the following exception:
17:47:05:
17:47:05: Traceback (most recent call last):
17:47:05: File "/home/gui/dev/TwitchDropsMiner/main.py", line 158, in main
17:47:05: await client.run()
17:47:05: File "/home/gui/dev/TwitchDropsMiner/twitch.py", line 765, in run
17:47:05: await self._run()
17:47:05: File "/home/gui/dev/TwitchDropsMiner/twitch.py", line 810, in _run
17:47:05: await self.fetch_inventory()
17:47:05: File "/home/gui/dev/TwitchDropsMiner/twitch.py", line 1669, in fetch_inventory
17:47:05: await self.gui.inv.add_campaign(campaign)
17:47:05: File "/home/gui/dev/TwitchDropsMiner/gui.py", line 1347, in add_campaign
17:47:05: campaign_image = await self._cache.get(campaign.image_url, size=(108, 144))
17:47:05: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17:47:05: File "/home/gui/dev/TwitchDropsMiner/cache.py", line 106, in get
17:47:05: async with self._twitch.request("GET", url) as response:
17:47:05: File "/usr/lib/python3.11/contextlib.py", line 204, in __aenter__
17:47:05: return await anext(self.gen)
17:47:05: ^^^^^^^^^^^^^^^^^^^^^
17:47:05: File "/home/gui/dev/TwitchDropsMiner/twitch.py", line 1495, in request
17:47:05: response = await self.gui.coro_unless_closed(
17:47:05: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17:47:05: File "/home/gui/dev/TwitchDropsMiner/gui.py", line 2050, in coro_unless_closed
17:47:05: return await next(iter(done))
17:47:05: ^^^^^^^^^^^^^^^^^^^^^^
17:47:05: File "/home/gui/dev/TwitchDropsMiner/env/lib/python3.11/site-packages/aiohttp/client.py", line 1174, in throw
17:47:05: return self._coro.throw(*args, **kwargs)
17:47:05: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17:47:05: File "/home/gui/dev/TwitchDropsMiner/env/lib/python3.11/site-packages/aiohttp/client.py", line 578, in _request
17:47:05: raise ServerTimeoutError(
17:47:05: aiohttp.client_exceptions.ServerTimeoutError: Connection timeout to host https://static-cdn.jtvnw.net/ttv-boxart/515025.jpg
17:47:05:
17:47:05: Exiting...
17:47:05: INFO: Websocket[0] stopped.
17:47:05:
17:47:05: Application Terminated.
17:47:05: Close the window to exit the application.
But here's the thing, that URL opens instantly on my web browser (and even with curl
):
Click me to expand
$ time curl -I https://static-cdn.jtvnw.net/ttv-boxart/515025.jpg
HTTP/2 200
content-type: image/png
content-length: 568456
server: nginx
last-modified: Tue, 05 Dec 2023 17:24:07 GMT
x-amz-server-side-encryption: AES256
x-amz-version-id: 7IapvVNbt2WJVDtvqEggrwa8UXyblDFx
access-control-allow-origin: *
access-control-allow-methods: GET, OPTIONS
timing-allow-origin: https://www.twitch.tv
accept-ranges: bytes
date: Fri, 02 Feb 2024 20:49:42 GMT
expires: Sat, 03 Feb 2024 00:49:42 GMT
cache-control: max-age=14400
etag: "10e1c0495de9b0586a6d1139bed6c863"
vary: Accept-Encoding
x-cache: Hit from cloudfront
via: 1.1 65ffb2ded43b3ae52e7d29216ce6b644.cloudfront.net (CloudFront)
x-amz-cf-pop: GRU3-P2
x-amz-cf-id: 9a_6JVIISxLZfZE5Sv9LjuvEDKAHLHmfmbXx5PpX9ccXASzEVhyKIw==
age: 31
________________________________________________________
Executed in 270.12 millis fish external
usr time 19.72 millis 301.00 micros 19.42 millis
sys time 0.03 millis 29.00 micros 0.00 millis
DNS resolution of static-cdn.jtvnw.net
is working fine on the rest of the system, too:
Click me to expand
$ time nslookup static-cdn.jtvnw.net
Server: 127.0.0.1
Address: 127.0.0.1#53
Non-authoritative answer:
static-cdn.jtvnw.net canonical name = jtvnw.twitchcdn.net.
jtvnw.twitchcdn.net canonical name = d186rixkn5ruba.cloudfront.net.
Name: d186rixkn5ruba.cloudfront.net
Address: 108.139.184.218
Name: d186rixkn5ruba.cloudfront.net
Address: 2600:9000:2619:e800:19:f28c:cd92:c761
Name: d186rixkn5ruba.cloudfront.net
Address: 2600:9000:2619:2a00:19:f28c:cd92:c761
Name: d186rixkn5ruba.cloudfront.net
Address: 2600:9000:2619:4800:19:f28c:cd92:c761
Name: d186rixkn5ruba.cloudfront.net
Address: 2600:9000:2619:ae00:19:f28c:cd92:c761
Name: d186rixkn5ruba.cloudfront.net
Address: 2600:9000:2619:7000:19:f28c:cd92:c761
Name: d186rixkn5ruba.cloudfront.net
Address: 2600:9000:2619:d200:19:f28c:cd92:c761
Name: d186rixkn5ruba.cloudfront.net
Address: 2600:9000:2619:6000:19:f28c:cd92:c761
Name: d186rixkn5ruba.cloudfront.net
Address: 2600:9000:2619:e200:19:f28c:cd92:c761
________________________________________________________
Executed in 28.27 millis fish external
usr time 10.09 millis 438.00 micros 9.65 millis
sys time 6.45 millis 31.00 micros 6.42 millis
I'm out of ideas to debug this further.
EDIT: Great, I started the app in debug mode (-vvvv
), and everything began working. I restarted in normal mode, and everything worked as well. Whatever this was, it was most likely temporary... -_-
aiohttp.client_exceptions.ServerTimeoutError: Connection timeout to host https://static-cdn.jtvnw.net/ttv-boxart/515025.jpg
That looks like just a server timeout. An actual one. The miner was working as intended :slightly_smiling_face: It should succeed once the server responds again.
everything began working. I restarted in normal mode, and everything worked as well.
Heh :smile: Yeah, requests and connection stability is something each application just needs to take care of. There's many things that can go wrong, the server goes down, the internet connection is down or simply struggling at the time, poor wi-fi signal, the list is quite long. I wonder if there should be some more variety to the error messages, as it's only really just this one, and one that says "Twitch is down", but that only displays on 5XX responses from the server.
I reliably get the "cannot connect" message after a while, now, too. Beginning to wonder if there's some intentional behavior on the server's part to pooch TDM. I'll see if I'm getting any interesting error messages when I have time to troubleshoot.
Since there was no reports on this for a while now, I'm assuming this issue has resolved itself, and can now be closed.