Note that there are some explanatory texts on larger screens.

plurals
  1. PODuplex communication using NetTcpBinding - ContractFilter mismatch?
    primarykey
    data
    text
    <p>I'm making slow and steady progress towards having a duplex communication channel open between a client and a server, using NetTcpBinding. (FYI, you can observe my newbie progress <a href="https://stackoverflow.com/q/4461591/7850">here</a> and <a href="https://stackoverflow.com/q/4526284/7850">here</a>!)</p> <p>I'm now at the stage where I have successfully connected to my server, through the server's firewall, and the client can make requests of the server.</p> <p>In the other direction, however, things aren't quite so happy. It works fine when testing on my own machine, but when testing over the internet, when I try to initiate a callback from the server side, I get an error:</p> <pre><code>The message with Action 'http://MyWebService/IWebService/HelloWorld' 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). </code></pre> <p>Here are some of the key bits of code. First, the web interface:</p> <pre><code>[ServiceContract(Namespace = "http://MyWebService", SessionMode = SessionMode.Required, CallbackContract = typeof(ISiteServiceExternal))] public interface IWebService { [OperationContract] void Register(long customerID); } public interface ISiteServiceExternal { [OperationContract] string HelloWorld(); } </code></pre> <p>Here's the implementation of IWebService:</p> <pre><code>[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] class WebService : IWebService { void IWebService.Register(long customerID) { Console.WriteLine("customer {0} registering", customerID); var callbackService = OperationContext.Current.GetCallbackChannel&lt;ISiteServiceExternal&gt;(); RegisterClient(customerID, callbackService); Console.WriteLine("customer {0} registered", customerID); } } </code></pre> <p>Then, on the client side (I was fiddling with these attributes without really knowing what I'm doing):</p> <pre><code>[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, Namespace="http://MyWebService")] class SiteServer : IWebServiceCallback { string IWebServiceCallback.HelloWorld() { return "Hello World!"; } ... } </code></pre> <p>So what am I doing wrong here?</p> <p><strong>EDIT:</strong> Adding app.config code. From server:</p> <pre><code>&lt;system.serviceModel&gt; &lt;diagnostics&gt; &lt;messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" logEntireMessage="true" maxMessagesToLog="1000" maxSizeOfMessageToLog="524288" /&gt; &lt;/diagnostics&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="mex"&gt; &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt; &lt;serviceMetadata/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;services&gt; &lt;service name ="MyWebService.WebService" behaviorConfiguration="mex"&gt; &lt;endpoint address="net.tcp://localhost:8000" binding="netTcpBinding" contract="MyWebService.IWebService" bindingConfiguration="TestBinding" name="MyEndPoint"&gt;&lt;/endpoint&gt; &lt;endpoint address ="mex" binding="mexTcpBinding" name="MEX" contract="IMetadataExchange"/&gt; &lt;host&gt; &lt;baseAddresses&gt; &lt;add baseAddress="net.tcp://localhost:8000"/&gt; &lt;/baseAddresses&gt; &lt;/host&gt; &lt;/service&gt; &lt;/services&gt; &lt;bindings&gt; &lt;netTcpBinding&gt; &lt;binding name="TestBinding" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" portSharingEnabled="false"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength ="8192" maxArrayLength ="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/&gt; &lt;security mode="None"/&gt; &lt;/binding&gt; &lt;/netTcpBinding&gt; &lt;/bindings&gt; &lt;/system.serviceModel&gt; </code></pre> <p>and on the client side:</p> <pre><code>&lt;system.serviceModel&gt; &lt;bindings&gt; &lt;netTcpBinding&gt; &lt;binding name="MyEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt; &lt;security mode="None"&gt; &lt;transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"&gt; &lt;extendedProtectionPolicy policyEnforcement="Never" /&gt; &lt;/transport&gt; &lt;message clientCredentialType="Windows" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/netTcpBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint address="net.tcp://mydomain.gotdns.com:8000/" binding="netTcpBinding" bindingConfiguration="MyEndPoint" contract="IWebService" name="MyEndPoint" /&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload