Tags: tarantool-php/client
Tags
Force closing a persistent connection via StreamConnection::close()
This is necessary in cases of "out-of-sync" errors or when re-authentication
is required. How to test/reproduce:
// test_auth.php
<?php
// Run php -S localhost:8000 test_auth.php,
// then open the http://localhost:8000/?close=0 page
// and then http://localhost:8000/?close=1
// (authentication must be initiated for both requests)
declare(strict_types=1);
use Tarantool\Client\Client;
use Tarantool\Client\Middleware\AuthenticationMiddleware;
require __DIR__.'/vendor/autoload.php';
$client = Client::fromDsn('tcp://localhost:3301?persistent=true');
$client = $client->withMiddleware(new AuthenticationMiddleware('guest'));
if (isset($_REQUEST['close']) && $_REQUEST['close']) {
$client->getHandler()->getConnection()->close();
}
$client->ping();
PreviousNext