eee
This commit is contained in:
@@ -17,13 +17,17 @@ function faker($page = 0)
|
|||||||
|
|
||||||
run(function () {
|
run(function () {
|
||||||
$offset = 1;
|
$offset = 1;
|
||||||
|
|
||||||
|
$success = 0;
|
||||||
for ($i = 1; $i <= 10000; $i++) {
|
for ($i = 1; $i <= 10000; $i++) {
|
||||||
$faker = faker($offset);
|
$faker = faker($offset);
|
||||||
$offset++;
|
$offset++;
|
||||||
go(function () use ($faker, $offset) {
|
go(function () use ($faker, $offset, &$success) {
|
||||||
$socket = new Swoole\Coroutine\Http\Client('43.248.128.57', 14101);
|
$socket = new Swoole\Coroutine\Http\Client('43.248.128.57', 14101);
|
||||||
$socket->upgrade("/ws?access_token=" . $faker['params']['token']);
|
$socket->upgrade("/ws?access_token=" . $faker['params']['token']);
|
||||||
if ($socket->connected) {
|
if ($socket->connected) {
|
||||||
|
$success += 1;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
$socket->recv();
|
$socket->recv();
|
||||||
// $socket->push('hello');
|
// $socket->push('hello');
|
||||||
@@ -32,13 +36,15 @@ run(function () {
|
|||||||
Coroutine::sleep(0.1);
|
Coroutine::sleep(0.1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$success -= 1;
|
||||||
|
|
||||||
echo 'websocket fail: ' . socket_strerror($socket->errCode) . PHP_EOL;
|
echo 'websocket fail: ' . socket_strerror($socket->errCode) . PHP_EOL;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Coroutine::sleep(0.1);
|
Coroutine::sleep(0.1);
|
||||||
|
|
||||||
var_dump($offset);
|
var_dump($success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user