繁体   English   中英

电报Api错误503服务不可用

[英]Telegram Api Error 503 Service Unavailable

我在主机上有一个电报机器人。

一天后...机器人无法正常工作。

getwebhookinfo是说:

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

我也使用PHP测试ping api.telegram.org,

<?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

如何解决呢?


新更新

添加添加print_r调试curl到我的机器人代码:

$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

接下来,我在笔记本电脑(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):

同样在运行此命令后,我从我的机器人收到消息!

如何解决?

您可以通过将类似的数据发布到服务器来发现问题, 这里有一些数据可以在curl -d JSON ,只需将其复制并在自己的服务器上运行即可。

顺便说一句,检查您的CDN配置(如果您已在该服务器上应用),暂时禁用泛洪或进行任何检查。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM