You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel调用Telegram Bot API遇cURL error 35:连接被对等方重置

Laravel请求Telegram Bot API报错cURL error 35: Recv failure: Connection reset by peer

报错信息:

cURL error 35: Recv failure: Connection reset by peer

我在Laravel中配置了如下路由,通过Http客户端触发Telegram机器人发送消息,但内部发起POST请求时出现上述错误。手动携带必要参数访问该API URL可正常发送消息,但Laravel内请求失败。

路由代码:

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;

Route::get('bot', function (Request $request) {
    $url = 'https://api.telegram.org/bot<my-token>/sendMessage';

    Http::connectTimeout(20)->post($url, [
        'chat_id' => '<chat-id>',
        'text' => 'Got a new request!'
    ]);
});

已尝试的解决方案

  • 检查URL与参数:手动访问URL确认正常,API地址和参数无误。
  • 禁用SSL验证:临时关闭SSL验证后仍报错:
Http::withOptions(['verify' => false])
  • 指定SSL/TLS版本:强制使用TLS 1.2,问题依旧:
Http::withOptions(['curl' => [CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2]])
  • 尝试直接使用GuzzleHttp\Client发起请求,仍出现相同错误。

环境信息

  • Laravel版本:11.2
  • Ubuntu版本:24.04 LTS
  • cURL版本:8.5.0
  • PHP版本:8.3.6
  • Nginx版本:1.24.0

内容的提问来源于stack exchange,提问作者Amir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 02:00:15