On server curl method - return "TCP connection reset by peer"


#1

Hi there.
I created web application with telegram bot(he posting messages in telegram channel), in local machine works fine, but on server(with https, ssl, cloudflare) - NO,

PHP script - request:
$text = $message_title.$message_body.$message_link;
$site = “h ttps://api.telegram.org/bot”.$toke n;

    $params = [
        'chat_id' => '@'.$chanelId,
        'text' => $text,
        'parse_mode' => $parse_mode,
    ];

    $options = array(
        CURLOPT_RETURNTRANSFER => true,     // return web page
        CURLOPT_HEADER         => false,    // don't return headers
        CURLOPT_FOLLOWLOCATION => true,     // follow redirects
        CURLOPT_ENCODING       => "",       // handle all encodings
        CURLOPT_USERAGENT      => "spider", // who am i
        CURLOPT_AUTOREFERER    => true,     // set referer on redirect
        CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
        CURLOPT_TIMEOUT        => 120,
        CURLOPT_POSTFIELDS     => $params,  // timeout on response
        CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
        CURLOPT_SSL_VERIFYPEER => false,    // Disabled SSL Cert checks
    );

    $ch      = curl_init( $site.'/sendMessage' );
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );

    $header['errno']   = $err;
    $header['errmsg']  = $errmsg;
    $header['content'] = $content;

    echo '<pre>';
    print_r($header);
    echo '</pre>';
    die(); 

On local machine i have response:
Array
(
[url] => h ttps://api.telegram.org/bot#############/sendMessag e
[content_type] => application/json
[http_code] => 200
[header_size] => 409
[request_size] => 297
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.514426
[namelookup_time] => 0.060566
[connect_time] => 0.134252
[pretransfer_time] => 0.288472
[size_upload] => 443
[size_download] => 377
[speed_download] => 732
[speed_upload] => 861
[download_content_length] => 377
[upload_content_length] => 443
[starttransfer_time] => 0.361662
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => #######
[certinfo] => Array
(
)

[primary_port] => ######
[local_ip] => #######
[local_port] => ######
[errno] => 0
[errmsg] => 
[content] => {"ok":true,"result":{"message_id":76,"chat":{"id":-1001305077429,"title":"#######","username":"#######","type":"channel"},"date":1529406800,"text":"qwe\n\nqwe\n\n\u0427\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435","entities":[{"offset":0,"length":3,"type":"bold"},{"offset":10,"length":15,"type":"text_link","url":"h ttps://########.ru/post/42 7"}]}}

)

On server:
Array
(
[url] => https://api.telegram.org/bot#########/sendMessage
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.221272
[namelookup_time] => 0.028652
[connect_time] => 0.06342
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => #######
[certinfo] => Array
(
)

[primary_port] => ######
[local_ip] => #####
[local_port] => ######
[errno] => 35
[errmsg] => TCP connection reset by peer
[content] => 

)


#2

What ist the port that is used by your bot?


#3

[primary_port] => 443
[local_ip] => 172.17.0.72
[local_port] => 34130