$connection = $request->connection;
$connection->send(new Response(200, array('Content-Type' => 'application/octet-stream', 'Transfer-Encoding' => 'chunked'), 'hello'));
$con = new AsyncTcpConnection("tcp://www.baidu.com:80");
$con->onConnect = function ($con) {
$con->send("GET / HTTP/1.1\r\nHost: www.baidu.com\r\nConnection: keep-alive\r\n\r\n");
};
$con->onMessage = function ($con, $data) use ($connection) {
$connection->send("HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nTransfer-Encoding: chunked\r\n\r\n你好世界~");
// print_r(new Chunk('你好世界~'));
// $connection->send(new Chunk('你好世界~'));
$connection->send(new Chunk(''));
};
$con->connect();
$connection->send(new Chunk('hello'));
$connection->send(new Chunk('world'));
$connection->send(new Chunk('!'));
// $connection->send(new Chunk(''));
输出结果 hellohelloworld!
onMessage 中send的信息都没有输出
使用的webman 1.5.0 代理服务器为vite的proxy
$connection->send(new Chunk(''));为啥要注释?
这个是调试的时候做的,我知道要以这个结尾,经过多次测试就是发现onMessage 这里面send的数据不被代理服务器接收到,怀疑是vite的代理服务有点儿问题