AsyncTcpConnection 如何连接https服务器?

猴子

连接以后提示 The plain HTTP request was sent to HTTPS port.

3275 6 0
6个回答

walkor 打赏

AsyncTcpConnection不支持https

  • 暂无评论
猴子

牛人,有没有可能让他支持?框架非常赞啊。不支持的话始终有点遗憾

  • 暂无评论
walkor 打赏

https://github.com/walkor/Workerman
支持了,请更新下Workerman的代码

http://doc.workerman.net/components/workerman-http-client.html

<?php
require __DIR__ . '/vendor/autoload.php';
use Workerman\Worker;
$worker = new Worker();
$worker->onWorkerStart = function(){
    $http = new Workerman\Http\Client();

    $http->get('https://example.com/', function($response){
            var_dump($response->getStatusCode());
            echo $response->getBody();
        }, function($exception){
            echo $exception;
        });

    $http->post('https://example.com/', ['key1'=>'value1','key2'=>'value2'], function($response){
            var_dump($response->getStatusCode());
            echo $response->getBody();
        }, function($exception){
            echo $exception;
        });

    $http->request('https://example.com/', [
            'method'  => 'POST',
            'version' => '1.1',
            'headers' => ['Connection' => 'keep-alive'],
            'data'    => ['key1' => 'value1', 'key2'=>'value2'],
            'success' => function ($response) {
                echo $response->getBody();
            },
            'error'   => function ($exception) {
                echo $exception;
            }
        ]);
};
Worker::runAll();
  • 暂无评论
猴子

非常感谢

  • 暂无评论
walkor 打赏

不客气

  • 暂无评论
猴子

已经更新

  • 暂无评论
年代过于久远,无法发表回答
×
🔝