RSS-Bridge / rss-bridge

The RSS feed for websites missing it
https://rss-bridge.org/bridge01/
The Unlicense
6.96k stars 1.02k forks source link

cURL error : 23 #4101

Open sal0max opened 1 month ago

sal0max commented 1 month ago

Describe the bug Since quite some time (2024-04-04), ExplosmBridge doesn't work any more. However, I suspect the reason being somewhere in the rss-bridge libs. This is the error I get:

-- Details
Type: HttpException
Code: 0
Message: cURL error : 23 (https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://explosm.net/comics/latest#comic
File: lib/http.php
Line: 154

-- Trace
#0 index.php(72): RssBridge->main()
#1 lib/RssBridge.php(103): DisplayAction->execute()
#2 actions/DisplayAction.php(65): DisplayAction->createResponse()
#3 actions/DisplayAction.php(114): ExplosmBridge->collectData()
#4 bridges/ExplosmBridge.php(36): getSimpleHTMLDOM()
#5 lib/contents.php(164): getContents()
#6 lib/contents.php(85): CurlHttpClient->request()
#7 lib/http.php(154)

-- Context
Query: action=display&bridge=ExplosmBridge&limit=5&format=Html
Version: 2024-02-02 (git.master.1c3024f)
OS: Linux
PHP: 8.1.28 

To Reproduce Steps to reproduce the behavior: Add ExpolsmBridge and try to get the feed.

Expected behavior Getting the feed.

dvikan commented 1 month ago
CURLE_WRITE_ERROR (23)

An error occurred when writing received data to a local file, or an error was returned to libcurl from a write callback. 

full disk?

read-only fs?

sal0max commented 1 month ago

Yeah... the error message baffles me, too.

No, all other bridges run flawlessly.

dvikan commented 1 month ago

the explosm bridge caches for 2 hours. you are probably seeing a cache result?

or does the error continue to persist?

if error is only for explosm it is very strange.

TLDR: libcurl is unable to write to fs

sal0max commented 1 month ago

I tested some stuff and in that process set the cache time to 0. And as mentioned: The problem exists since 2024-04-04.

At first, I thought the error is due to changes on the website. It seems, that the CSS selectors wouldn't work any more, as classes have changed. But the error message clearly states to look in lib/http.php.

dvikan commented 1 month ago

the stack trace has this message:

Message: cURL error : 23 

there is a curl error message missing here. did you modify it?

rss-bridge throws like this:

            $curl_error = curl_error($ch);
            $curl_errno = curl_errno($ch);
            throw new HttpException(sprintf(
                'cURL error %s: %s (%s) for %s',
                $curl_error,
                $curl_errno,
                'https://curl.haxx.se/libcurl/c/libcurl-errors.html',
                $url
            ));

anyways i think problem is in curl_setopt($ch, CURLOPT_HEADERFUNCTION which returns 0 due to bug in rss-bridge.

dvikan commented 1 month ago

if you are able to reproduce you can try this patch:

diff --git a/lib/http.php b/lib/http.php
index 39f0c727..0c8a3896 100644
--- a/lib/http.php
+++ b/lib/http.php
@@ -116,6 +116,9 @@ final class CurlHttpClient implements HttpClient
         $responseHeaders = [];
         curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($ch, $rawHeader) use (&$responseHeaders, &$responseStatusLines) {
             $len = strlen($rawHeader);
+            if ($len === 0) {
+                throw new \Exception('wtf? ' . $rawHeader);
+            }
             if ($rawHeader === "\r\n") {
                 return $len;
             }
sal0max commented 1 month ago

I tried the patch, but the if-clause doesn't catch. Still the same error message:

Message: cURL error : 23 (https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://explosm.net/comics/latest#comic 

I removed the if-clause and just threw the Exception. Result:

Message: wtf? HTTP/2 307