docker 集群部署问题 stream_socket_client(): unable to connect to tcp://172.25.70.8:2900

xjkeyser

在 docker 集群部署中如果 分成3个应用 gateway register bussiness 。gateway 启动两个容器不会出险问题。但当 gateway 启动3个的时候就会报如下错误 ErrorException: stream_socket_client(): unable to connect to tcp://172.25.70.8:2900 (Connection timed out) in /data/nas/codes/wanjia-video/vendor/workerman/gateway-worker/src/Lib/Gateway.php:759
172.25.70 为第三个容器的本地 IP 。环境和配置如下。麻烦大神看一下。用的是阿里云的容器服务器
composer 配置文件如下

tv: &phprunner
  restart: always
  #build: .
  image: wjdocker.lab/wanjia/tv
  volumes:
    - $PWD:/var/www
    - ~/wanjia/confs:/data/nas/codes/confs
  ports:
    - "7080:80"
  links:
    - message-register:message-register
  environment: &phprunner-env
    APP_GIT_URL: git:run/wanjia-video.git
    APP_INIT_SCRIPT: /usr/local/bin/app_init
    APP_START_SCRIPT: /var/www/docker/app_start
    PUBLISH_SSH_KEY: |
      -----BEGIN RSA PRIVATE KEY-----
      换成部署私钥
      并保持这种缩进模式
      -----END RSA PRIVATE KEY----

qdaemon:
  <<: *phprunner
  ports: []
  environment:
    <<: *phprunner-env
    APP_ROLE: noweb nofpm q_default

message-register:
  <<: *phprunner
  links: []
  ports: []
#  labels:
#    aliyun.routing.port_80: 'http://message_register'       #QDaemon 服务不对外提供服务,但是要覆盖掉 laravel 服务中定义的字段
  environment:
    <<: *phprunner-env
    APP_ROLE: noweb nofpm message_register

message-business:
  <<: *phprunner
  ports: []
#  labels:
#    aliyun.routing.port_80: 'http://message_business'       #QDaemon 服务不对外提供服务,但是要覆盖掉 laravel 服务中定义的字段
  environment:
    <<: *phprunner-env
    APP_ROLE: noweb nofpm message_business

message-gateway:
  <<: *phprunner
  ports:
    - 8383:8383
#  labels:
#    aliyun.routing.port_80: 'http://message_gateway'       #QDaemon 服务不对外提供服务,但是要覆盖掉 laravel 服务中定义的字段
  environment:
    <<: *phprunner-env
    APP_ROLE: noweb nofpm message_gateway

config 配置文件 ----
return ;

启动脚本如下 ------------

if ($instance_type == 'register') {
    Register::$pidFile = storage_path('app/workerman.reg.pid');
    Register::$logFile = storage_path('logs/workerman.reg.log');
    $register = new Register('text://0.0.0.0:1238');
    Worker::runAll();
}

if ($instance_type == 'gateway') {
    Gateway::$pidFile = storage_path('app/workerman.gw.pid');
    Gateway::$logFile = storage_path('logs/workerman.gw.log');

    $gateway = new VideoGateway("websocket://0.0.0.0:8383");
    $gateway->name = 'YourAppGateway';
    $gateway->count = 4;
    $gateway->lanIp = gethostbyname(gethostname());
    $gateway->startPort = 2900;
    $gateway->registerAddress = config('FT.video.wokerman_register_ip');
    $gateway->pingInterval = 45;
    $gateway->pingNotResponseLimit = 1;
    $gateway->pingData = "";
    Worker::runAll();
}

if ($instance_type == 'business') {
    BusinessWorker::$pidFile = storage_path('app/workerman.bw.pid');
    BusinessWorker::$logFile = storage_path('logs/workerman.bw.log');
    $worker = new BusinessWorker();
    $worker->name = 'YourAppBusinessWorker';
    $worker->count = 6;
    $worker->registerAddress = config('FT.video.wokerman_register_ip');
    $worker->eventHandler = ImEventHandler::class;
    Worker::runAll();
}
4341 1 0
1个回答

th

多看看文档,错误很明显

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