-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warning: socket_write(): unable to write to socket #57
Comments
Is your DB located on a remote server? |
@andreyvk : Yes |
Is your connection to the remote server unstable? Have you tried catching a |
What I mean is something like this. Of course this code below need more refining: $client = getPhpOrientClient(); //suppose this is your custom function to instantiate a connection
//try to do queries. if socket error happens more than 3 times, then quit
$errorCnt = 0;
do {
try {
//do your queries here
}
catch(SocketException $e) {
$errorCnt++;
$client = getPhpOrientClient();
}
}
while($errorCnt < 3);
if($errorCnt >= 3) {
//some serious issue happened
} |
I understand The OrientDb client is injected in the application with all credentials, calling the dbOpen method, before I use it. It seems not possible in Symfony to reset the connexion. I've looked into the project, I was thinking that if I put the transport = null, it will recreate the transport. (PhpOrient line 174) I would think to create a decorator to PhpOrient client, and add a method to reconnect. Maybe it could be something valuable for the PhpOrient class ? |
I see, I completely overlooked that you were using Symphony. Sorry I found that there's a If that doesnt work then maybe @Ostico can help a little here. |
Hi @lgoix , there are some methods to reset/renew the connection for PhpOrient, surely the most simple one is to use it's internal transport layer to manually create a connection on the underlying OrientSocket: use PhpOrient\PhpOrient;
use PhpOrient\Protocols\Binary\SocketTransport;
$config = [
"hostname" => "localhost",
"port" => 2424,
"connect" => [
"username" => "root",
"password" => "root"
]
];
$client = new PhpOrient();
$transport = new SocketTransport();
$this->assertInstanceOf( '\PhpOrient\Protocols\Common\AbstractTransport', $transport );
$this->assertInstanceOf( '\PhpOrient\Protocols\Common\TransportInterface', $transport );
$transport->configure( $config );
$client->setTransport( $transport );
$client->execute( 'connect' );
$this->assertNotEquals( -1, $client->getTransport()->getSessionId() );
$this->assertNotEquals( -1, $client->getTransport()->getProtocolVersion() ); So, you can inject a new socket inside your already configured client. $old_transport = $client->getTransport( );
$new_transport = new SocketTransport();
$transport->configure( $config );
$client->setTransport( $transport ); |
Hi Ostico, If you don't configure the |
Hello
I have a consumer that consume message from RabbitMQ. It means the php file is executed as long the supervisor don't stop it, or it die by itself.
The consumer select and insert into OrientDB. Sometime there is a problem with the socket connection with OrientDB and it will produce many exception:
The PhpOrient class is instanciated in Symfony2 with the service configurator.
I want to know if there is a way to reset the connection ? Is reseting the transport interface is a way to do it ?
Thanks
The text was updated successfully, but these errors were encountered: