lossless1024 / StreaMonitor

Adult live stream downloader for advanced people. I could have chosen a better name.
GNU General Public License v3.0
204 stars 53 forks source link

[SC] An existing connection was forcibly closed by the remote host #133

Open farrel219 opened 8 months ago

farrel219 commented 8 months ago

Hi all.

Just started for me this morning, the error messages are generated by StreaMonitor when recording from Stripchat. Otherwise, the program record normally from Chaturbate. Anyone who can help correct this issue?

Thanks.

Traceback (most recent call last): File "E:\StreaMonitor-master\streamonitor\bot.py", line 125, in run self.sc = self.getStatus() ^^^^^^^^^^^^^^^^ File "E:\StreaMonitor-master\streamonitor\sites\stripchat.py", line 34, in getStatus r = requests.get('https://stripchat.com/api/vr/v2/models/username/' + self.username, headers=self.headers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\api.py", line 73, in get return request("get", url, params=params, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 589, in request resp = self.send(prep, send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 703, in send r = adapter.send(request, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 501, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\ urllib3\connectionpool.py", line 790, in urlopen response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "C:\Users\Adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\ urllib3\connectionpool.py", line 491, in _make_request raise new_e urllib3.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:992)

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

Traceback (most recent call last): File "C:\Users\Adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\ requests\adapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "C:\Users\Adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\ urllib3\connectionpool.py", line 844, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "C:\Users\Adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\ urllib3\util\retry.py", line 515, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type ] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='stripchat.com', port =443): Max retries exceeded with url: /api/vr/v2/models/username/z_xinxin (Cause d by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:992) ')))

nacrissa commented 8 months ago

Look like they have implemented some mechanism to block non-browser clients, it's interesting... I'm wondering which information allows them to do that.

DerBunteBall commented 8 months ago

The status request still works. That's network related. I think two things are possible:

  1. Blocked by the site based on IP which leads to a unconvinient blocking by doing TLS wrong.
  2. Something intercepts TLS connections.

Best Regards

farrel219 commented 8 months ago

Can I use VPN to solve this problem?

DerBunteBall commented 8 months ago

The spawning of ffmpeg isn't the problematic part.

The status request fails.

Another possible issue could be the SSL/TLS Stack. stripchat.com has a really small and "hard" cipher suite active. So everything under TLS 1.2 isn't allowed the heavily use EC stuff and so on.

This could lead to problems with older Python versions. While Python on Linux/BSD/macOS is build with OpenSSL it should be no problem. I'm not sure whether Python is build with Windows Crypto Stuff on Windows. So the OpenSSL version or Windows could be also a problem in certain cases.

Line 992 of _ssl.c indicates that the Handshake fails (just based on a short look).

So make sure to have at least 3.11.x Python (3.12 seems to not work with StreaMonitor) and check your Crypto Stuff and with which Python is build.

nacrissa commented 8 months ago

At first, I also thought it could be that SC has disabled TLS 1.0 and 1.1 support, causing the issue. However, when forcing the request to use TLSv1.3, the issue still persists. I tried making requests on various systems, including MacOS and Unix, across different AWS Lightsail regions (such as us-west, asia-southeast, etc.), and the result remains consistent. It seems that the connection reaches Cloudflare, but it's being refused.

curl --tlsv1.3 -X GET -H "Referer: https://stripchat.com/" -H "Origin: https://stripchat.com/" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 OPR/107.0.0.0" "https://stripchat.com/" -i
HTTP/1.1 406 Not Acceptable
Date: Sun, 25 Feb 2024 13:11:42 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
x-branch: master
x-ssr-cache-status: MISS
x-backend: india-ssr-application-5d4746dbc6-9szlb
Content-Encoding: identity
x-frame-options: deny
CF-Cache-Status: DYNAMIC
Set-Cookie: __cf_bm=rj7WT44kCjhmZ6YfqNVWXmIkPiHuMVT5MZuA3vcz0K8-1708866702-1.0-Ad5SylumsPyoHBxKjGqRoUl61KoHXLCEgEl+AeWW+pLIQpjH73c/UF/f/M3vtpXRH4yYK1BW8wASNtCyS3FaIxwJf73PXPsfCPPRJo5EH+nd; path=/; expires=Sun, 25-Feb-24 13:41:42 GMT; domain=.stripchat.com; HttpOnly; Secure; SameSite=None
Set-Cookie: __cflb=02DiuFntVtrkFMde1diGSa8jTNcHXKN3uuDwYTkjj4xrQ; SameSite=None; Secure; path=/; expires=Mon, 26-Feb-24 12:11:42 GMT; HttpOnly
Server: cloudflare
CF-RAY: 85b0320af88784cd-HKG
alt-svc: h3=":443"; ma=86400
DerBunteBall commented 8 months ago
  1. The exception the Python requests module thorws is related to TLS.
  2. They have TLS1.2 and TLS1.3 activated with a thin cipher suite. Aspecially the handshake algorithms are EC stuff.
  3. You get a working TLS connection. The reason you get a 406 HTTP Error is simply related to the fact that the server wants to see a Accept header. Just send a valid Accept Header like a browser would do and you can curl the mainpage. If your IP isn't blocked (DC, Hoster and some other IP-ranges can be generally blocked via CF).
xAstroBoy commented 8 months ago

Reference in new i

make a fork and if you believe you can fix this issue, i have been trying to fix it for a week.