5

We have a problem whereby after making a certain (larger) number of requests to the Core Service, the requests begin to time out with the following message:

The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

The failure is on:

Tridion.ContentManager.CoreService.Client.ISessionAwareCoreService.Read(String id, ReadOptions readOptions)

When initializing the core service client we do this:

ISessionAwareCoreService coreServiceClient = factory.CreateChannel(); 

I suspect, given other posts, that the problem is that the coreServiceClient is not disposed of once we've finished with it, and thus we get to a point where we are unable to create any further connections.

Other posts on a similar topic: /WebUI/Models/TCM54/Services/General.svc/GetUserSettings taking TEN minutes to respond

Is there a way to dispose of the coreServiceClient when we are finished with it, and does this seem like a plausible cause of the issue?

6

You should definitely dispose of the client once you're done with it. Increasing timeouts is always an option but most of the time it's just masking an issue and not confronting the root cause.

To dispose the client:

In 2013 you can do:

if (_client.State == CommunicationState.Faulted)
{
    _client.Abort();
}
else
{
    _client.Close();
}

For Web 8 and later, you can do the following:

_client.Dispose();

Or simply use a using block which will call dispose for you.

See here


UPDATE

Based on the comment.

You can switch your implementation to the SessionAwareCoreServiceClient class (the rest of the code remains the same). To instantiate it, you can use the following code fragment (with the appropriate constructor (for example with the EndPointConfigurationName)):

SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient();
  • The problem I have is that the ISessionAwareCoreService type used is not implicitly convertible to System.IDisposable. I don't have any of those aforementioned commands available on my ISessionAwareCoreService instance. – Harald Greve Dec 12 '18 at 17:20
  • Updated my answer – Atila Sos Dec 12 '18 at 18:41
3

Besides everything Atila said in his answer, i would like to state that you can use ChannelFactory class also to instantiate web client and use it like in the snippet bellow:

using (ChannelFactory<ISessionAwareCoreService> chanelFactory = new ChannelFactory<ISessionAwareCoreService>(endpoint))
{
    chanelFactory.Credentials.Windows.ClientCredential = new NetworkCredential(coreServiceUser, coreServicePass);
    ISessionAwareCoreService client = chanelFactory.CreateChannel();
  //use client here
}

Please make note that it is also instantiating client within using blocks, so its auto disposed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.