Telegram Api Error 503 Service Unavailable

2.3k views Asked by At

i have a telegram bot at a host.

after some day... bot not work.

getwebhookinfo is say :

has_custom_certificate:false

pending_update_count:1

last_error_date:1504179338

last_error_message:Wrong response from the webhook: 503 Service Unavailable

max_connections:40

i also test ping api.telegram.org using PHP,

<?php
$wait = 1; // wait Timeout In Seconds
$host = 'api.telegram.org';
$ports = [
    'http'  => 80,
    'https' => 443,
    'ftp'   => 21,
];
foreach ($ports as $key => $port) {
    $fp = @fsockopen($host, $port, $errCode, $errStr, $wait);
    echo "Ping $host:$port ($key) ==> ";
    if ($fp) {
        echo 'SUCCESS';
        fclose($fp);
    } else {
        echo "ERROR: $errCode - $errStr";
    }
    echo PHP_EOL;
}

Ping api.telegram.org:80 (http) ==> SUCCESS Ping api.telegram.org:443 (https) ==> SUCCESS Ping api.telegram.org:21 (ftp) ==> ERROR: 110 - Connection timed out

how can fix this?


New Update

add add print_r debug curl to my bot code:

$curl = curl_init('https://api.telegram.org/bot'.$token.'/sendMessage');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($param));
$response = curl_exec($curl);
$code = curl_getinfo($curl);
curl_close($curl);
print "\n=========\n".$response."\n\n";======>for debug
print_r($code);======>for debug
print "\n\n";======>for debug

next , i run this command on my laptop(os:gnu/linux).

$ curl --tlsv1 -v -k -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache"  -d '{
> "update_id":10000,
> "message":{
>   "date":1441645532,
>   "chat":{
>      "last_name":"Test Lastname",
>      "id":381078330,
>      "first_name":"Test",
>      "username":"Test"
>   },
>   "message_id":1365,
>   "from":{
>      "last_name":"Test Lastname",
>      "id":381078330,
>      "first_name":"Test",
>      "username":"Test"
>   },
>   "text":"/start"
> }
> }' "********"

....

HTTP/1.1 200 OK
Server: nginx/1.10.0
Date: Thu, 31 Aug 2017 12:43:26 GMT
Content-Type: application/json
Content-Length: 370
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Expose-Headers: Content-Length,Content-Type,Date,Server,Connection
Strict-Transport-Security: max-age=31536000; includeSubdomains

{"ok":true,"result":{"message_id":262747,"from":{"id":4464**352,"is_bot":true,"first_name":"*****","username":"******"},"chat":{"id":3810***330,"first_name":"***","type":"private"},"date":1504183406,"text":"test"}}

Array
(
    [url] => https://api.telegram.org/bot****/sendMessage
    [content_type] => application/json
    [http_code] => 200
    [header_size] => 384
    [request_size] => 212
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.535426
    [namelookup_time] => 1.9E-5
    [connect_time] => 0.126365
    [pretransfer_time] => 0.392713
    [size_upload] => 27
    [size_download] => 370
    [speed_download] => 370
    [speed_upload] => 27
    [download_content_length] => 370
    [upload_content_length] => 27
    [starttransfer_time] => 0.535413
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => 149.154.167.197
    [certinfo] => Array
        (
        )

    [primary_port] => 443
    [local_ip] => 185.55.225.100
    [local_port] => 38420
)



Done.
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):

also after run this command , i receive message from my bot!

How can fix?

1

There are 1 answers

0
Sean Wei On

You can find out problem by POST similar data to your server, here have some data you can use in curl -d JSON, just copy it and run on your own server.

BTW, check your CDN config (if you had applied on that server), temporary disable flooding or any check.