Workerman retransmission problem

//SOCKET
    public  function Connect($info)
    {
        $val=$info;
        $w_file = "../config.txt";
        file_put_contents($w_file,$val,FILE_APPEND);//"W+"
        set_time_limit(0);
        $host = self::TCP_SER_HOST;
        $port = self::TCP_SER_PORT;
        $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)or die("Could not create socket\n"); // Socket
        socket_set_option($socket,SOL_SOCKET,SO_RCVTIMEO,array("sec"=>self::SO_RCVTIMEO, "usec"=>0 ) );//7s
        socket_set_option($socket,SOL_SOCKET,SO_SNDTIMEO,array("sec"=>self::SO_RCVTIMEO, "usec"=>0 ) );//7s
        $connection = socket_connect($socket, $host, $port) or die("Could not connet TCP server\n"); 
        socket_write($socket, $val) or die("Write failed\n"); //  ,fd
        while (true) 
        {
             $buff = socket_read($socket, 1024);//   
               if($buff)
            {
                $back=$buff;
                break;
            }
            else
            {
                $back="{"kill":"kill","err":-10}";
                break;
            }
        }
        $back=json_decode($back, true);
        socket_shutdown($socket);
        socket_close($socket);
        return $back;
    }    

the figure shows that the socket, of the client connects to the gatewayworker, through it using the tcp protocol

now there are two problems:
problem one: when the client socket is called to send data to the server, it will be resent, excluding the page refresh. At the same time, the log is recorded in the first line of the connect () function, and the retransmission instruction is found, which is basically resent after one minute. My instruction is similar to {"syn": "log", "time": 120}, and then a minute later, there will be another instruction {"syn": "log", "time": 60}, the time is exactly one minute, this situation sometimes happens all the time, sometimes it does not happen, does printing a reissue instruction on the first line of the connect () function indicate that the function has been called again?

question 2: when I print data in the events file of gatewayworker, I can see the data sent by my client to the server, which is sent to the device by the server, and then the data sent by the device to the server, from the instruction initiated by the client to the response from the server, which takes only two or three seconds, but my client keeps showing the communication timeout, as you can see from the figure. I set the communication timeout time is 7 seconds, send and receive is 7 seconds, but from the data printed by the server, the server has received the device reply instruction, but the socket client has not received it for a long time. Why?

also ask the Great God for advice

Jun.21,2021

{"syn": "log", "time": 120} A minute later, {"syn": "log", "time": 60}
shows what went wrong with the business logic. See where such a package can be assembled may be helpful for positioning

on the second question, it depends on whether the business code sends the return data to the client that the server wrote to you. Of course, you can't receive it without it.

Menu