In a network built for HTTP applications, your long-lived LDAP connections can get cut by network equipment configured to treat idle and even just old connections as stale resources to reclaim.
When you maintain a particularly long-lived connection such as a connection for a persistent search, periodically perform a health check to make sure nothing on the network quietly decided to drop your connection without notification. A health check might involve reading an attribute on a well-known entry in the directory.
OpenDJ LDAP SDK offers
Connections.newHeartBeatConnectionFactory()
methods to
ensure your ConnectionFactory
serves connections that
are periodically checked to detect whether they are still alive.