监听http端口 获取重复消息

alpha
 public function onWorkerStart() {
        // 监听一个 http 端口
        $inner_http_worker = new Workerman( 'http://0.0.0.0:2288' );
        // 当 http 客户端发来数据时触发
        $inner_http_worker->onMessage = function( TcpConnection $http_connection ) {
            $input              = input();
            $input['type_name'] = $input['type_name'] ?? '未知';
            $input['type']      = $input['type'] ?? 'publish';
            // 推送数据的 url 格式 type=publish&to=uid&content=xxxx
            if ( !isset( $input['uuid'] ) ) return $http_connection->send( 'false' );
            dump( $input );

            return $http_connection->send( 'ok' );

        };

        // 执行监听
        $inner_http_worker->listen();
    }

如上面 我用http请求这个ip:port 会重复打印两次 请问是什么原因

678 1 0
1个回答

six

浏览器会多发一个 ico 请求,所以两个

  • alpha 2022-08-23

    看到了 确实是这样。这个有什么解决办法吗

  • six 2022-08-23

    自己判断下,ico就返回404

  • alpha 2022-08-23

    好的 感谢

年代过于久远,无法发表回答
🔝