Gatwayworker is distributed, and the server cannot find all clients. SendToAll is not successful and can only be sent to the client that connects to the current server.

both servers have business logic processing code: Event.php, the content is the same, but cannot sendToALL to all clients connected to the two servers, which can only be sent to their respective clients

A server is deployed normally.
B server does not write the registered address of start_register.php,bussinessWorker service and Gateway to A server, that is, A server monitors the services of the two servers.

The

B server code is as follows:
start_gateway.php
use WorkermanWorker;
use WorkermanWebServer;
use GatewayWorkerGateway;
use GatewayWorkerBusinessWorker;
use WorkermanAutoloader;

/ / gateway process, which uses the Text protocol, and can be tested with telnet
$gateway = new Gateway (_ gateway_PORT_);
/ / gateway name. Status makes it easy to see
$gateway- > name = "YourAppGateway";
/ / gateway processes
$gateway- > count = 3;
/ / Native ip, use the intranet ip
$gateway- > lanIp =" 0.0.0.0" for distributed deployment
/ / Internal communication starting port. If $gateway- > count=4, the starting port is 4000
/ /, then 4000 4001 4002 4003 ports are generally used as the internal communication port
$gateway- > startPort = _ startPort_;
/ / Service Registration address, pointing to A server
$gateway- > registerAddress = _ registerAddress_;

/ / heartbeat interval
$gateway- > pingInterval = 15 pingData action2 10 set to 0 means no heartbeat detection is sent
$gateway- > pingNotResponseLimit = 30;
/ / heartbeat data
$gateway- > pingData ="{"action2": "ping"}";

/ *
/ / when the client connects, set the onWebSocketConnect of the connection, that is, the callback in the websocket handshake
$gateway- > onConnect = function ($connection)
{

$connection->onWebSocketConnect = function($connection , $http_header)
{
   
};

};
* /

/ / if it is not started in the root directory, run the runAll method
if (! defined ("GLOBAL_START")) {

Worker::runAll();

}
? >
start_businessworker_chat.php
/ * *

  • This file is part of workerman.

*

  • Licensed under The MIT License
  • For full copyright and license information, please see the MIT-LICENSE.txt
  • Redistributions of files must retain the above copyright notice.

*

* /
use WorkermanWorker;
use WorkermanWebServer;
use GatewayWorkerGateway;
use GatewayWorkerBusinessWorker;
use WorkermanAutoloader;
use GlobalDataClient;

/ / bussinessWorker process
$worker = new BusinessWorker ();
/ / worker name
$worker- > name = "ChatBusinessWorker";
/ / number of bussinessWorker processes
/ / only one process can be started, and different inter-process variables are impassable
$worker- > count = 10;

/ / set the service timeout for 10 seconds, which needs to cooperate with the business
$worker- > processTimeout = 10;

/ / the service registration address points to A server
$worker- > registerAddress = _ registerAddress_;
$worker- > onWorkerStart = function ($worker)
{/ / GlobalData server is the same as this project, if there are multiple chat servers to separate it

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

};
/ / if it is not started in the root directory, run the runAll method
if (! defined ("GLOBAL_START")) {

Worker::runAll();

}
? >

Jun.16,2022

$gateway- > lanIp Private network address cannot be written in full 0.register. Use this to find gateway

gate1

$gateway = new Gateway("Websocket://0.0.0.0:8282");
// gatewaystatus
$gateway->name = 'gate2';
// gateway
$gateway->count = 4;
// ipip
$gateway->lanIp = '192.168.1.28';
// $gateway->count=44000
// 4000 4001 4002 4003 4 
$gateway->startPort = 2900;
// 
$gateway->registerAddress = '192.168.1.59:1238';

gate2

$gateway = new Gateway("Websocket://0.0.0.0:8283");
// gatewaystatus
// gatewaystatus
$gateway->name = 'gate1';
// gateway
$gateway->count = 4;
// ipip
$gateway->lanIp = '192.168.1.59';
// $gateway->count=44000
// 4000 4001 4002 4003 4 
$gateway->startPort = 2910;
// 
$gateway->registerAddress = '192.168.1.59:1238';
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bea860-31a09.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bea860-31a09.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?