首页 > 解决方案 > cURL 错误 28:连接在 1001 毫秒后超时(参见 http://curl.haxx.se/libcurl/c/libcurl-errors.html)

问题描述

我正在使用 laravel 框架。AWS SNS 服务借助附加的链接在我的项目中使用并安装了所有 requiremnet。

https://www.kerneldev.com/2018/01/03/send-sms-in-laravel-using-aws-sns/

但出现 cURL 错误 28:连接在 1001 毫秒后超时(请参阅http://curl.haxx.se/libcurl/c/libcurl-errors.html

删除了旧的访问密钥和秘密密钥,并在 aws 控制台中添加了新的,并在 config/aws.php 中更改了密钥

在 DNS 设置中添加了所有 TXT 和 DKIM 记录

创建的网络路由

Route::get('/sendSMS/{phone_number}', 'SMSController@sendSMS');

创建控制器

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use AWS;

class SMSController extends Controller
{
    protected function sendSMS($phone_number){
        $sms = AWS::createClient('sns');

        $sms->publish([
                'Message' => 'Hello, This is just a test Message',
                'PhoneNumber' => $phone_number,
                'MessageAttributes' => [
                    'AWS.SNS.SMS.SMSType'  => [
                        'DataType'    => 'String',
                        'StringValue' => 'Transactional',
                     ]
                 ],
              ]);
    }
}

标签: laravelamazon-web-services

解决方案


替换CURLOPT_TIMEOUT_MSCURLOPT_CONNECTTIMEOUT_CurlFactory.php.

$conf[CURLOPT_CONNECTTIMEOUT] = $options['timeout'] * 10000;  

这对我有用,试试吧。


推荐阅读