Rev
Rev

Reputation: 2275

WCF callback timeout and Visual Studio catastrophic failure

A kind of stupid error, but this happened when I wanted to call client by server-side-service (WCF Duplex):

The message could not be transferred within the allotted wcf callback timeout of 00:01:00, There was no space available in the reliable channel's transfer window

Also something mysterious happened too. In the login method when I called service if user and password be wrong I find sender-callback and then call GetError method on sender to show logical error like "User is wrong". This works well, but if user and password is correct and have access, I got that error (same for all other client-side methods - in all these methods I send more data than simple strings, I was send geterror) !

Edit 2: As I say in most of the callback methods, I was send data like data-context (LINQ to SQL) data-class (list or single row). So might this be my problem or not!
(But this isn't my first time, using WCF-duplex, also with send data-struct in callback methods , I'm so astounding.)

Also after that error I got this error on,

Screen unable to process request from service http://server:15450/service.svc catastrophic failure

Edit 3: Service configuration:

 <system.serviceModel>
    <services>
      <service name="ContactServer.Business.ContactService"
               behaviorConfiguration="ServiceBehavior">
        <endpoint address=""
                  binding="wsDualHttpBinding"
                  contract="ContactServer.Business.IContactService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange"
                  name="MexBinding"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

and Client Config

  <system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_ContactService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
          textEncoding="utf-8" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" />
          <security mode="Message">
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:1408/ContactService.svc"
        binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ContactService"
        contract="ServiceReference.ContactService" name="WSDualHttpBinding_ContactService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

More information: I use .NET 3.5 and Visual Studio 2010. Also after rising timeout on the client side I still got the same error, with 00:01:00 Time. Why did this happen?

Upvotes: 2

Views: 1877

Answers (1)

vortexwolf
vortexwolf

Reputation: 14037

The problem is concerning transfer of entities from a WCF-service.

For example, we have this database model: enter image description here

Entity Framework:

    public Item GetItem(int id)
    {
        var se = new SampleEntities();
        return se.Items.FirstOrDefault(i => i.Id == id);
    }

The code doesn't seem to be wrong, but in reality it will return the item with all related items.

        var s = new SampleServiceClient();
        var item = s.GetItem(1);
        Assert.AreEqual(item.RelatedItems.Any(), true); //equal

It is especially dangerous if we have many-to-many relations in the database. So lazy loading should be disabled (you can disable them just before the return):

var se = new SampleEntities();
se.ContextOptions.LazyLoadingEnabled = false;
return se.Items.FirstOrDefault(i => i.Id == id);

Linq to SQL

    public Item GetItem(int id)
    {
        var dc = new DataClasses1DataContext();
        return dc.Items.FirstOrDefault(i => i.Id == id);
    }

We have an exception:

There was an error while trying to serialize parameter :GetItemResult. The InnerException message was 'Object graph for type 'WebApplication1.RelatedItem' contains cycles and cannot be serialized if reference tracking is disabled.'.

You must open DataContext diagramm and set Properties->SerializationMode->Unindirectional. Here is a more complete explanation.

Upvotes: 2

Related Questions