Docker with php8.2(php82) curl sends 50% times with "53" error

1. I use docker with alpine (VERSION_ID=3.19.0 PRETTY_NAME=“Alpine Linux v3.19”)**

2.There i install from docker compose:

RUN apk upgrade && apk update
RUN apk add php82
RUN apk add php82-curl

COPY php.ini /etc/php82/php.ini (the same file that gives me after installing php, but I changed “short_open_tag = On”)

3. After that i go into the container and try php (PHP version 8.2) The script I’m using worked fine on a simple PHP host, fine Post to console:

**/usr/bin/php /var/www/html/poster_bot/du/index.php**

at this step i have problem, this line activate php script to send curl to telegram api, 50% of activate this script are executed, 50 - not. I start find log errors - empty (or ok, or empty response) I add curl_error and curl_errno and find false and 56 error This CURL and code with errors checkers underneath:

//send function to telegram

function post($url, $postContent){  
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postContent);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);
    $result = curl_exec($curl);

    if (json_encode($result) === 'false') {
        //throw new Exception(curl_error($ch), curl_errno($ch));
    return $result;


26.01.24 18:26:36 -----
26.01.24 18:26:36
26.01.24 18:26:36 56
26.01.24 18:26:36 -----
26.01.24 18:26:36 false
26.01.24 18:26:36

4. At this point i’m stuck. This error i supposed is (CURLE_RECV_ERROR (56) Failure with receiving network data.) I try open, forwarding ports on docker - no effect, check firewall on mother PC (Windows 10) - no effect. I don’t know why 50% of requests are fulfilled. Why is the remaining 50% not being executed?

After I try to downgrade to PHP 7.4 Alpine. I have got the same program behavior. BUT the error has changed. I got error curl: (92) HTTP/2 stream 1 was not closed cleanly before end of the underlying stream. Then i gave up, and start topic on stackoverflow (.

After I try install docker FROM php:7.3-apache there i get 52 error and same behavior

Thanks for attention, and thank you.

Is the script working on your host PC without Docker?

What target URL do you use? Maybe they have two servers and one is dead at the moment or you run into a limit with every second request, need to throttle more.

Send to telegram api. You are right, I was 100% sure that everything was sending from the host PC since everything worked recently. There appeared additional data - OpenSSL SSL_read: Connection was reset, errno 10054. I tried to find solution but nothing. Sending with delay not helps.
I will solve this sending that it several times through the cycle Anyway thanks for help