rss-bridge icon indicating copy to clipboard operation
rss-bridge copied to clipboard

cURL error : 23

Open sal0max opened this issue 1 year ago • 11 comments

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.

sal0max avatar May 12 '24 14:05 sal0max

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?

dvikan avatar May 12 '24 18:05 dvikan

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

No, all other bridges run flawlessly.

sal0max avatar May 13 '24 01:05 sal0max

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

dvikan avatar May 13 '24 01:05 dvikan

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.

sal0max avatar May 13 '24 01:05 sal0max

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 avatar May 13 '24 01:05 dvikan

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;
             }

dvikan avatar May 13 '24 01:05 dvikan

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 

sal0max avatar May 13 '24 19:05 sal0max

did u ever find the mysterious source of this bug

dvikan avatar Jun 18 '24 18:06 dvikan

It still occurs with every call of that source. But I didn't find time yet to investigate the issue, sorry.

sal0max avatar Jun 21 '24 18:06 sal0max

is the file system samba or some other kind of network fs?

lemme know if u find root cause

dvikan avatar Jan 02 '25 16:01 dvikan

Minor observation: 307 = temporary redirect cURL has not followed the redirect, whether this is intended or not I don't know.

Also the bridge is working on my instance.

8gb2 avatar Feb 17 '25 09:02 8gb2