When a swoole client receives a message from the server, the two are merged into one.

the following is the log of the client on the server

ConfigInit demo ... 
config server judge 
ConfigInit -> init 
get_swoole_client 
pms_config:9502 
ConfigInit -> init end 
Receive: s:22:"!";
 
Receive: s:6:"wocao!";
 
ConfigInit demo ... 
config server judge 
ConfigInit -> init 
get_swoole_client 
pms_config:9502 
ConfigInit -> init end 
Receive: s:22:"!";
s:6:"wocao!";
 
ConfigInit demo ... 
config server judge 
ConfigInit -> init 
get_swoole_client 
pms_config:9502 
ConfigInit -> init end 
Receive: s:22:"!";
s:6:"wocao!";
 
ConfigInit demo ... 
config server judge 
ConfigInit -> init 
get_swoole_client 
pms_config:9502 
ConfigInit -> init end 
Receive: s:22:"!";
 
Receive: s:6:"wocao!";

Receive is the callback function received. The code is as follows:

/**
     * 
     * @param \swoole_client $cli
     * @param $data
     */
    public function receive(\swoole_client $cli, $data)
    {
        echo "Receive: $data \n";

    }

the server keeps sending serialized "illegal controller" and "wocao" to the client twice (an interval of 1 second). Sometimes the client receives it separately, sometimes it merges it together. What if the server sends two serialized "illegal controllers" and "illegal controllers" to the client? Can"t receive it together, is there any way to handle the callback!
solve!
the above code is used for the communication between two service, the reference of swoole: https://wiki.swoole.com/wiki/.

.
Feb.27,2021

set your own protocol


has not used swoole, but this looks like a sticky package, you can turn off the Nagle algorithm to try, TCP_NODELAY.
or the receiver processes at the application layer

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-1bd45fb-3929b.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-1bd45fb-3929b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?