views:

44

answers:

4

Hi there.

I have a very strange problem. I have a WCF service and a console application that invokes some of it methods. At some point, it can't invoke one of them any more. It just calls the method, but it never enters it. It just waits and waits.. and nothing ever happens.

Should I maybe somehow refresh the service client? I tried creating a new service client object

QueryingServiceClient queryingClient = new QueryingServiceClient();

and then to call the method again, but it didn't work. Just to add that I call that method and several other ones few times before it stops working.

Any ideas?

Thanks.

A: 

Is it the same number of times before it stops? Are you reaching a connection limit perhaps?

How is your WCF service instanced?

Singleton, Session, PerCall?

Could you post the config section for your client and server endpoint?

Does it work consistently if you use the WcfClient tool?

MattC
I posted my reply down there, but I forgot to mention that the number of times before it stops is not always the same.
Ivan
A: 

That's strange, it wouldn't wait and wait forever. You should be getting a WCF timeout exception. What is the timeout value in your app.config?

If you aren't getting any timeout exceptions, then it might be the case you aren't calling that service method. I know it's obvious but sometimes methods with long names can be confused for each other. If you are debugging the client too, you must have ruled that out, though.

henginy
A: 

Thanks for your replies.

It's not forever, I didn't express myself correctly. After some time I get the following exception:

The maximum retry count has been exceeded with no response from the remote endpoint. The reliable session was faulted. This is often an indication that the remote endpoint is no longer available.

It's a singleton. This is part of the app.config:

<system.serviceModel>
    <bindings>
          <wsHttpBinding>
                <binding name="WSHttpBinding_QueryingService" closeTimeout="00:25:00"
                      openTimeout="00:25:00" receiveTimeout="00:25:00" sendTimeout="00:25:00"
                      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                      maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
                      messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                      allowCookies="false">
                      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                            maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                            maxNameTableCharCount="2147483647" />
                      <reliableSession ordered="true" inactivityTimeout="00:25:00"
                            enabled="true" />
                      <security>
                            <transport>
                                  <extendedProtectionPolicy policyEnforcement="Never" />
                            </transport>
                      </security>
                </binding>
...

On the provider side:

<wsHttpBinding>
    <binding name="wsHttpConfig" maxReceivedMessageSize="2147483647" receiveTimeout="00:25:00">
      <readerQuotas maxDepth="2147483647"
                    maxStringContentLength="2147483647"
                    maxArrayLength="2147483647"
                    maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647" />
      <reliableSession enabled="true" ordered="true" />
    </binding>
  </wsHttpBinding>

...

<service name="Platform.WSLA.Impl.Services.Querying.QueryingService"
           behaviorConfiguration="Default.Behavior">

    <endpoint address="http://localhost:8004/Platform/wsla/querying/QueryingService"
              binding="wsHttpBinding"
              bindingConfiguration="wsHttpConfig"
              contract="Platform.WSLA.Contracts.Services.Querying.IQueryingService" />
    <endpoint address="mex"
              binding="mexHttpBinding"
              name="MetadataExchange"
              contract="IMetadataExchange" />

    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8004/Platform/wsla/querying" />
      </baseAddresses>
    </host>

  </service>
Ivan
Sound like your service is falling over and then not responding. Have you tried turning on tracing? http://blogs.msdn.com/b/madhuponduru/archive/2006/05/18/601458.aspxandhttp://geekswithblogs.net/mnf/archive/2008/10/03/use-wcf-message-logging.aspx
MattC
I turned it on, but it's not much help.
Ivan
A: 

Assumptions:

  • your service uses the Session instance mode (the default mode)
  • your client creates a new instance of the proxy for every call it makes to the service.
  • your client does not dispose the proxies after the calls.

The problem is probably that you are depleting the number of available slots (sessions in that case) on the server to the point where you are reaching the maximum number of concurrent sessions. Then your client will wait depending on the defined timeout for a session to be closed on the service side (which obviously will never happen in that case).

Suggested fixes:

  • Set the InstanceContextMode to PerCall, unless you really need WCF sessions.
  • Always close your proxies after use.

EDIT:

using (var proxy = new Proxy())
{
    // Use the proxy as much as needed
    proxy.Method();
}
Johann Blais
I tried to put to PerCall, but id didn't help. About the proxies, I'm not sure how to do that.. Any newbie help?
Ivan
I have edited my answer.
Johann Blais
It seems it helped. Thanks!
Ivan