Closed silvafabio closed 1 year ago
This is by design, it reflects whether it was explicitly closed or not. I'll see if I can make some changes to detect broken connections.
Thanks for the quickly reply ;-)
As a workaround I'm reinstantiating the FBEventManager every 10 minutos.
while (!interrupt) {
if (eventManager == null || !eventManager.isConnected()) {
// instantiate the FBEventManager
// add listeners to eventManager
nextEventManagerRenew = LocalDateTime.now().plusMinutes(10);
}
if(LocalDateTime.now().isAfter(nextEventManagerRenew)){
try{
if(eventManager != null && eventManager.isConnected()){
eventManager.close();
}
} catch (Exception e) {
// Log exception
} finally {
eventManager = null;
}
}
}
When I call eventManager.close() in a lost connection it's stuck forever.
This is another point to keep in mind when thinking in "some changes to detect broken connections".
Thanks again
With Jaybird 5, you could try if setting setSoTimeout
will improve detection of broken connections
I did a search in the repository source code and did not find a way to get access to setSoTimeout
through FBEventManager.
It's only available at:
I'm using:
eventManager = new FBEventManager();
eventManager.setHost(host);
eventManager.setUser(user);
eventManager.setPassword(password);
eventManager.setDatabase(database);
eventManager.connect();
It is available with Jaybird 5 on EventManager
/FBEventManager
, given you mention in your starting post you're using Jaybird 4.0.6, you will need to upgrade to Jaybird 5 first.
After upgrading, you can call eventManager.setSoTimeout
(e.g. eventManager.setSoTimeout(5000)
for a timeout of 5000 milliseconds).
Ok, Sorry, now I see the heritage of AttachmentProperties.java
I'll give a try and let you know.
Upgrading to Jaybird 5.0.1 and using the setSoTimeout(5000)
solves the eventManager.close() stucks forever part ;-)
Thanks
You're welcome. I am working on some changes which should detect fatal connection errors and mark the event manager as not connected, but those will only be added to Jaybird 6.
Hi.
I'm using EventManager in asynchronous mode and sometimes the connection between application and firebird server may experience some rarely instability.
When I first instantiate FBEventManager and call connect method it's works as expected, connecting if everything is fine between application and firebird server, or throwin java.sql.SQLNonTransientConnectionException otherwise.
But after the first successfully connection the method isConnected always reports true, even if the connection was down.
It's turns impossible to detect when the connection is down and prevents (silently) the application to receive the events.
I'm using jaybird-jdk18:4.0.6.java8
Thanks