WebObjects: LDAPAdaptor Stops Responding When Trying to Use Channel to Refetch

This article describes a WebObjects issue where LDAPAdaptor stops responding when trying to refetch, and provides a workaround.

Symptom:

LDAPAdaptor stops responding when trying to use channel to refetch a second time.


Solution

The LDAPAdaptor in WO 4.5 never disconnects from the directory server after fetching. However, most directory servers will sever the connection after 30 minutes. The adaptor thinks that the channel is still valid when you try to connect after the server has severed the connection and the application will stop responding.

To correct this issue, explicitly close the LDAP channel once you are done with fetching.

In Objective-C

EOEditingContext *ec; // Assume this exists

EODatabaseContext *dbContext = [ec databaseContextForModelNamed:@"yourModel"];

EOAdaptorContext *adaptorContext = [dbContext adaptorContext];

// Close the channel

[[adaptorContext channels] lastObject] closeChannel];

In Java

EOEditingContext ec; // Assume this exists

EODatabaseContext dbContext = EOUtilities.databaseContextForModelNamed(ec,"yourModel");

EOAdaptorContext  adaptorContext = dbContext.adaptorContext();

// Close the channel

EOAdaptorChannel adaptorChannel = (EOAdaptorChannel)(adaptorContext.channels().lastObject());

adaptorChannel.closeChannel();

Published Date: Feb 18, 2012