Question

Context

I'm playing with WCF configuration, trying to enable reliable sessions.

When reliable sessions are disabled, everything works as expected, and the client can successfully connect to the server. As soon as I put enabled="true" in <reliableSession> in the Web.config of the service and the App.config of the client, the following exceptions is thrown when the client tries to open the connection:

The message with Action 'http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

There are many questions about this exception on Stack Overflow, but none of the answers seem to apply. For example, I checked that the receiveTimeout and inactivityTimeout are the same, that the context mode is PerSession both service and client-side, etc.

Here's the trace. You'll find below my configuration. What's wrong with it?

Trace

enter image description here

  • The exception in red is the one I quoted above.
  • The received message just before is a CreateSequence.
  • The message sent just after the exception is the addressing/fault message, intended to propagate the exception to the client.

Service-side configuration

<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  <bindings>
    <netTcpBinding>
      <binding name="netTcpEndpoint" sendTimeout="00:10:00" receiveTimeout="00:10:00">
        <reliableSession ordered="true" enabled="true" inactivityTimeout="00:10:00" />
        <security mode="Message">
          <message clientCredentialType="None" />
        </security>
      </binding>
    </netTcpBinding>
  </bindings>
  <services>
    <service behaviorConfiguration="DebugOrientedBehavior" name="Demo.PipeService">
      <endpoint address="Default.svc" binding="netHttpBinding"
        name="TransportLayerServiceEndpoint" contract="Demo2.IPipeService" />
      <host>
        <baseAddresses>
          <add baseAddress="http://[removed the public URI of the service]/Default.svc" />
        </baseAddresses>
      </host>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="DebugOrientedBehavior">
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

Client-side configuration

<system.serviceModel>
  <bindings>
    <netTcpBinding>
      <binding name="netTcpEndpoint" sendTimeout="00:10:00" receiveTimeout="00:10:00">
        <reliableSession ordered="true" inactivityTimeout="00:10:00" />
        <security>
          <message clientCredentialType="None" />
        </security>
      </binding>
    </netTcpBinding>
    <netHttpBinding>
      <binding name="TransportLayerServiceEndpoint">
        <reliableSession ordered="true" enabled="true" />
        <webSocketSettings transportUsage="Always" />
      </binding>
    </netHttpBinding>
  </bindings>
  <client>
    <endpoint address="ws://[removed the public URI of the service]/Default.svc/Default.svc"
      binding="netHttpBinding" bindingConfiguration="TransportLayerServiceEndpoint"
      contract="PipeServiceReference.IPipeService" name="TransportLayerServiceEndpoint" />
  </client>
</system.serviceModel>
Was it helpful?

Solution

On the server config enspoint add:

bindingConfiguration="netTcpEndpoint"

currently the binding configuration is not attached to the endpoint so the default net tcp settings are used. it was good before the change you made but not any more.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top