Understanding LDAP Provider in SAP Mobile Platform Server – Connection Pooling
LDAP provider, in SAP Mobile Platform (SMP) server, uses connection pooling to reuse connections to the directory server to avoid exhausting network resources. There are two different pools used by the provider. One is the “Administrator Connection pool” where the connections are established using the configured Administrator user credentials. The provider retrieves a connection from this pool to look up a user with a given username and the roles granted to the user etc. The second pool of connections is used for validating the user credentials by binding to the LDAP server using the credentials provided by the client as part of authentication process. Successful binding indicates that the credentials are valid.
Each connection pool, by default, can have a maximum of 8 active connections. This number can be configured using the configuration property “LDAP Pool Max Active”. This controls the maximum number of connections that can allocated by the pool (checked out to process requests, or idle in the pool) at one time. When a query is to be executed, a connection is checkout from the pool and is returned to the pool after executing the query and processing the results. If no connection is available in the pool, the pool will create a new connection as long as the number of active connections is less than the configured value. If the maximum connections are already created, the pool waits for one of them to be released before returning it to the requester.
If the connection stays idle in the pool for a long time, the LDAP directory server may detect idle connections open on its end and depending on its configuration, terminate the open socket. In some situations, this does not alert the network layer in SMP server that the socket has been closed.
When SMP server processes the next request and checks out such a connection, it might encounter an exception from the jndi library. When this happens, SMP server logs an INFO message to indicate that the connection will be destroyed and the query attempted using a new connection obtained from the pool.
“Error encountered when using the connection retrieved from the pool : <Error from the network layer>. Invalidating the connection and retrying the operation using another connection from the pool”
If the pool has previously grown to the maximum connections allowed and then left idle then the requester might have to cycle through as many such bad connections as the value of the configuration property “LDAP Pool Max Active”. This is expected behavior and is not an error. The SMP server will automatically cycle through such connections until it finds a valid connection in the pool. If all the idle connections in the pool need to be terminated, then a new connection will be created to process the request.