国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

[ERROR] stream_socket_client(): unable to connect to tcp://127.0.0.1:2902 (Connection refused)

phper1

PHP 框架使用的是 codeigniter4,前端用的是 uniapp,gatewayworker 從官網(wǎng)下載的 linux 版本,gatewayclient 使用composer 安裝。gatewayWorke、gatewayclient 和應(yīng)用使用同一服務(wù)器。

App/Gatewayworker/Applications/YourApp/start.gateway.php中只做了一處修改:將原來的:

$gateway = new Gateway(" tcp://0.0.0.0:8282");

改成了 websocket 協(xié)議:

$gateway = new Gateway("websocket://0.0.0.0:8282"); ```

App/Gatewayworker/Applications/YourApp/Events.php中,只對 onConnect 做了以下修改:

public static function onConnect($client_id)
{
Gateway::sendToClient($client_id, json_encode(array(
'type' => 'init',
'client_id' => $client_id
)));
// 向當(dāng)前client_id發(fā)送數(shù)據(jù)
Gateway::sendToClient($client_id, "Hello $client_id\r\n");
// 向所有人發(fā)送
Gateway::sendToAll("$client_id login\r\n");
}```

前端使用 websocket 連接,在收到'init'和 client_id的信息后,通過 bind_uid 接口向后臺上傳 uid 和 client_id 兩個參數(shù)。

后臺接收前端上傳的 uid 和 client_id 兩個參數(shù)后,進(jìn)行綁定。后臺代碼如下:

<?php namespace App\Controllers;
require_once '../vendor/autoload.php';
use CodeIgniter\Controller;
use App\Models\Push_model;
use GatewayClient\Gateway;

Class Push2 extends Controller
{
    public function __construct()
    {
        Gateway::$registerAddress = '127.0.0.1:1238';
    }

    public function bind_uid()
    {
        $uid       = $this->request->getPost('uid');
        $client_id = $this->request->getPost('client_id');
        try
        {
            Gateway::$registerAddress = '127.0.0.1:1238';
            Gateway::bindUid($client_id, $uid);
            $message = "binding is fixed";
            Gateway::sendToUid($uid, json_encode($message));
}
        catch (\Exception $e)
        {
            log_message('error', '[ERROR] {exception}', ['exception' => $e]);
        }
    }

問題:
1.前端上傳后,收不到返回的消息
2.打印錯誤日志,報如下內(nèi)容:

(Connection refused) /srv/vendor/workerman/gatewayclient/Gateway.php:1187
ERROR - 2021-08-28 08:28:03 --> [ERROR] stream_socket_client(): unable to connect to tcp://127.0.0.1:2903 (Connection refused) /srv/vendor/workerman/gatewayclient/Gateway.php:1188

已經(jīng)做過的嘗試:
1.服務(wù)器端口放行1238、2900、8282
2.重啟過 gateway 服務(wù)器
以上調(diào)整沒有效果。

請高手指點。十分期待,感謝感謝?。。?/p>

6128 3 0
3個回答

six

服務(wù)端debug運行,看下是不是有報錯。
或者運行php start.php status看

  • phper1 2021-08-29

    謝謝回復(fù)。

    服務(wù)端 debug 模式運行,不輸出錯誤。
    服務(wù)端 php start.php status,提示:

    Workerman[start.php] status 
    Workerman[start.php] not run
phper1

謝謝回復(fù)。

服務(wù)端 debug 模式運行,不輸出錯誤。
服務(wù)端 php start.php status,提示:

Workerman[start.php] status 
Workerman[start.php] not run
  • 暫無評論
six

咋會not run,not run就是沒啟動啊

  • phper1 2021-08-30

    是的,我目前的排除方向,是不是因為我用 docker,導(dǎo)致容器相互隔絕造成的。開放了端口我再測試一下。謝謝你~~

  • phper1 2021-08-31

    一圈下來,問題仍然沒有解決。php.start status 輸出 not run. 那這個沒有啟動的原因是什么呢?該怎么解決呢?

  • six 2021-09-04

    不用docker試下呢,排除docker問題

年代過于久遠(yuǎn),無法發(fā)表回答
??