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

channel client 啟動(dòng)的時(shí)候一連接就報(bào)錯(cuò)

jie365@126.com

PHP Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /data/www/admin/PushCommandService/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 195

    public function connect()
    {
        if ($this->_status !== self::STATUS_INITIAL && $this->_status !== self::STATUS_CLOSING &&
            $this->_status !== self::STATUS_CLOSED) {
            return;
        }
        $this->_status           = self::STATUS_CONNECTING;
        $this->_connectStartTime = \microtime(true);
        if ($this->transport !== 'unix') {
            if (!$this->_remotePort) {
                $this->_remotePort = $this->transport === 'ssl' ? 443 : 80;
                $this->_remoteAddress = $this->_remoteHost.':'.$this->_remotePort;
            }
            // Open socket connection asynchronously.
            if ($this->_contextOption) {
                $context = \stream_context_create($this->_contextOption);
                $this->_socket = \stream_socket_client("tcp://{$this->_remoteHost}:{$this->_remotePort}",
                    $errno, $errstr, 0, \STREAM_CLIENT_ASYNC_CONNECT, $context);
            } else {
                $this->_socket = \stream_socket_client("tcp://{$this->_remoteHost}:{$this->_remotePort}",
                    $errno, $errstr, 0, \STREAM_CLIENT_ASYNC_CONNECT);
            }
        } else {
            $this->_socket = \stream_socket_client("{$this->transport}://{$this->_remoteAddress}", $errno, $errstr, 0,
                \STREAM_CLIENT_ASYNC_CONNECT);
        }
        // If failed attempt to emit onError callback.
        if (!$this->_socket || !\is_resource($this->_socket)) {
            $this->emitError(\WORKERMAN_CONNECT_FAIL, $errstr);
            if ($this->_status === self::STATUS_CLOSING) {
                $this->destroy();
            }
            if ($this->_status === self::STATUS_CLOSED) {
                $this->onConnect = null;
            }
            return;
        }
        // Add socket to global event loop waiting connection is successfully established or faild.
        Worker::$globalEvent->add($this->_socket, EventInterface::EV_WRITE, array($this, 'checkConnection'));
        // For windows.
        if(\DIRECTORY_SEPARATOR === '\\') {
            Worker::$globalEvent->add($this->_socket, EventInterface::EV_EXCEPT, array($this, 'checkConnection'));
        }
    }

我的channel server 監(jiān)聽(tīng)的是172.16.0.177:2206
channel client 連接的也是 172.16.0.177:2206
而且我沒(méi)有使用80端口

$this->_socket = \stream_socket_client("tcp://{$this->_remoteHost}:{$this->_remotePort}",
$errno, $errstr, 0, \STREAM_CLIENT_ASYNC_CONNECT);

這行為何啟動(dòng)的時(shí)候warnning?

2086 1 1
1個(gè)回答

six

unable to connect to tcp://:80,很明顯,域名/ip沒(méi)有值

  • jie365@126.com 2022-01-17

    關(guān)鍵是我沒(méi)有監(jiān)聽(tīng)80端口

  • six 2022-01-17

    channel/client 代碼呢

  • jie365@126.com 2022-01-17

    //定時(shí)ping(心跳)
    Channel\Client::$pingInterval = 10;

        //連接到channel服務(wù)器
        Channel\Client::connect($this->configInfo['channel_server']['host'], $this->configInfo['channel_server']['port']);
    
        Channel\Client::$onConnect = function () {
            echo "{$this->nodeName}已經(jīng)連接上channel server" . PHP_EOL;
        };
    
        Channel\Client::$onMessage = function ($eventName, $eventData) {
            echo "{$this->nodeName}接收到channel server事件:{$eventName},內(nèi)容:{$eventData}" . PHP_EOL;
        };
    
        Channel\Client::$onClose = function () {
            echo "{$this->nodeName}已經(jīng)與channel server失去連接" . PHP_EOL;
        }
  • jie365@126.com 2022-01-17

    讀的都是配置文件,channel server 啟動(dòng)的時(shí)候都是用的這個(gè)配置文件

  • six 2022-01-17

    打印下配置看下對(duì)不對(duì)唄

  • jie365@126.com 2022-01-17

    AsyncTcpConnection的構(gòu)造器里加的打印信息
    public function __construct($remote_address, array $context_option = array())
    {
    error_log("--------{$remote_address}--------");

    ======分隔線=====
    打印信息如下
    --------frame://172.16.0.177:2206--------

    是完全跟我的配置對(duì)應(yīng)的

  • jie365@126.com 2022-01-17

    構(gòu)造器最后拿到的信息
    error_log("----{$this->transport}----{$this->_remoteHost}----{$this->_remotePort}----{$this->_remoteAddress}");

    ----tcp----172.16.0.177----2206----172.16.0.177:2206

  • six 2022-01-17

    $this->_remotePort = $this->transport === 'ssl' ? 443 : 80;

    從你貼的代碼看,如果沒(méi)傳端口號(hào)的話,自動(dòng)用80或443,所以我感覺(jué)是你的配置有時(shí)候可能讀不到,導(dǎo)致ip為空,端口默認(rèn)用了80?

  • jie365@126.com 2022-01-17

    有可能

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