网站有两台服务器AB,gateway分布式,AB两台服务器,起动报错?

AB两台服务器,A服务器有注册服务register,B服务器无,其它服务注册地址指向A服务器,A服务器独立启动没问题,B服务器一起动,两台都报错,报错代码如下:

PHP Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

PHP Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

PHP Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

PHP Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

PHP Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

PHP Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar1/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

GatewayConnection Error : 1 ,php_network_getaddresses: getaddrinfo failed: Name or service not known

GatewayConnection Error : 1 ,php_network_getaddresses: getaddrinfo failed: Name or service not known

GatewayConnection Error : 1 ,php_network_getaddresses: getaddrinfo failed: Name or service not known

B服务器报错如下:

PHP Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

PHP Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

GatewayConnection Error : 1 ,php_network_getaddresses: getaddrinfo failed: Name or service not known

PHP Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

PHP Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

GatewayConnection Error : 1 ,php_network_getaddresses: getaddrinfo failed: Name or service not known

PHP Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

PHP Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

Warning: stream_socket_client(): unable to connect to tcp://:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

GatewayConnection Error : 1 ,php_network_getaddresses: getaddrinfo failed: Name or service not known

PHP Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/wwwroot/testchar2/GatewayWorker/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 185

服血器原始代码如下

A服务器代码:

start.php

define('_gateway_PORT_',"websocket://0.0.0.0:29355");

define('_registerAddress_','0.0.0.0:1349');//服务注册地址

define('_register_text_','text://0.0.0.0:1349');//register 服务必须是text协议

define('_startPort_','3939');//内部通讯端口

define('_GlobalData_IP_','0.0.0.0');//

define('_GlobalData_PORT_','1234');//

ini_set('display_errors', 'on');

use Workerman\Worker;

use GlobalData\Server;

define('GLOBAL_START', 1);

require_once __DIR__ . '/vendor/autoload.php';

require_once __DIR__ . '/src/Server.php';

require_once __DIR__ . '/src/Client.php';

foreach(glob(__DIR__.'/Applications/*/start*.php') as $start_file)

{

require_once $start_file;

}

$worker = new GlobalData\Server(_GlobalData_IP_, _GlobalData_PORT_);

Worker::runAll();

start_register.php代码:

use \Workerman\Worker;

use \GatewayWorker\Register;

require_once __DIR__ . '/../../vendor/autoload.php';

$register = new Register(_register_text_);

if(!defined('GLOBAL_START'))

{

Worker::runAll();

}

start_gateway.php代码:

use \Workerman\Worker;

use \Workerman\WebServer;

use \GatewayWorker\Gateway;

use \GatewayWorker\BusinessWorker;

use \Workerman\Autoloader;

require_once __DIR__ . '/../../vendor/autoload.php';

$gateway = new Gateway(_gateway_PORT_);

$gateway->name = 'testws';

$gateway->count = 4;

$gateway->lanIp = 'A服务器内网IP';

$gateway->startPort = _startPort_;

$gateway->registerAddress = _registerAddress_;

if(!defined('GLOBAL_START'))

{

Worker::runAll();

}

start_businessworker.php代码:

use \Workerman\Worker;

use \Workerman\WebServer;

use \GatewayWorker\Gateway;

use \GatewayWorker\BusinessWorker;

use \Workerman\Autoloader;

use GlobalData\Client;

require_once __DIR__ . '/../../vendor/autoload.php';

$worker = new BusinessWorker();

$worker->name = 'intobustest';

$worker->count = 4;

// 服务注册地址

$worker->registerAddress = _registerAddress_;

$worker->onWorkerStart = function($worker)

{

global $globaldata;

$globaldata = new GlobalData\Client(_GlobalData_IP_.':'._GlobalData_PORT_);

};

if(!defined('GLOBAL_START'))

{

Worker::runAll();

}

B服务器代码如下:

start.php:

define('_gateway_PORT_',"websocket://0.0.0.0:29355");

define('_registerAddress_','A服务器公网地址:1349');//服务注册地址

define('_startPort_','4939');//内部通讯端口

define('_GlobalData_IP_','A服务器公网地址');//

define('_GlobalData_PORT_','1234');//

ini_set('display_errors', 'on');

use Workerman\Worker;

define('GLOBAL_START', 1);

require_once __DIR__ . '/vendor/autoload.php';

require_once __DIR__ . '/src/Client.php';

foreach(glob(__DIR__.'/Applications/*/start*.php') as $start_file)

{

require_once $start_file;

}

// 运行所有服务

Worker::runAll();

start_gateway.php:

use \Workerman\Worker;

use \Workerman\WebServer;

use \GatewayWorker\Gateway;

use \GatewayWorker\BusinessWorker;

use \Workerman\Autoloader;

require_once __DIR__ . '/../../vendor/autoload.php';

$gateway = new Gateway(_gateway_PORT_);

$gateway->name = 'YourAppGateway';

$gateway->count = 4;

// 本机ip,分布式部署时使用内网ip

$gateway->lanIp = '本机内网IP';

$gateway->startPort = _gateway_PORT_;

$gateway->registerAddress = _registerAddress_;

if(!defined('GLOBAL_START'))

{

Worker::runAll();

}

start_businessworker.php:

use \Workerman\Worker;

use \Workerman\WebServer;

use \GatewayWorker\Gateway;

use \GatewayWorker\BusinessWorker;

use \Workerman\Autoloader;

require_once __DIR__ . '/../../vendor/autoload.php';

$worker = new BusinessWorker();

$worker->name = 'YourAppBusinessWorker';

$worker->count = 4;

$worker->registerAddress = _registerAddress_;

$worker->onWorkerStart = function($worker)

{

global $globaldata;

$globaldata = new GlobalData\Client(_GlobalData_IP_.':'._GlobalData_PORT_);

};

if(!defined('GLOBAL_START'))

{

Worker::runAll();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值