2

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rev
  • 2,269
  • 8
  • 45
  • 75
  • 2
    @Rev: This story is fancy but what we need is more information about your service - service and callback behaviors, service and callback contracts, etc. Also about type of your client application. Btw. don't send DataContext over WCF - it doesn't work. – Ladislav Mrnka Jan 30 '11 at 21:58
  • 1
    Maybe you have a famous problem in WPF or Silverlight, where you should specify ConcurrencyMode=Reentrant. – vortexwolf Jan 31 '11 at 00:08
  • @Ladislav: I don't send total data-context over service or callback, only send one or two data-class(single row or list). – Rev Jan 31 '11 at 05:00
  • Have you tried to call the service without security mode? Just with standard settings. Also ConcurrencyMode shouldn't change anything, find an exact error why client can't call the service. – vortexwolf Jan 31 '11 at 11:25
  • There are attributes "security" and "reliableSession" in the client config. Tags "identity" are redundant too. Try to delete them. And set ConcurrencyMode=Multiple or Reentrant, because Single isn't a good choice. – vortexwolf Jan 31 '11 at 16:26
  • 1
    @Rev Another reason could be a serialization. I had a similar problem with EF when I sent an entity but serializer tried to serialize all relations. In your example I would try to pass a simple unreal object, and if it works without errors - search mistakes in the datacontext. – vortexwolf Feb 02 '11 at 12:23
  • @Vorrtex: thanks. After your comment I delete all relation between tables only in dataclasses and all callbacks work fine! so can you post comment as answer and give me more informatuion about this! – Rev Feb 02 '11 at 13:22

1 Answers1

2

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.

vortexwolf
  • 13,967
  • 2
  • 54
  • 72