WCF Net.TCP service throws incomprehensible errors

I am trying to enable an additional net.tcp endpoint (which uses user authentication) for an existing WCF service. The service is hosted on IIS7.

Running the client using the service returns an error that the socket connection was interrupted. Enabling tracing for a service detects the following exception:

System.ArgumentOutOfRangeException
The value of this argument must be positive.
Parameter Name: maxAccepts
The actual value is 0.

I am confused because, as far as I can tell, port sharing should be disabled by configuration (see below), but it still calls the port exchange code (again, as far as I can tell it). In any case, I cannot find a way to specify this value maxAccepts; Google knows nothing about this, and the value of maxPendingAccepts is not like that. How to fix the error?

The service configuration file contains the following for the net.tcp endpoint:

<bindings> <customBinding> <binding name="netTcp"> <security authenticationMode="UserNameOverTransport" /> <windowsStreamSecurity /> <tcpTransport portSharingEnabled="false" listenBacklog="10" maxPendingAccepts="10" maxPendingConnections="10" /> </binding> </customBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="netTcp"> <serviceDebug includeExceptionDetailInFaults="false" /> <serviceMetadata/> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Asi.Soa.ServiceModelEx.NullUserNamePasswordValidator, Asi.Soa.ServiceModelEx" /> <clientCertificate> <authentication certificateValidationMode="None"/> </clientCertificate> </serviceCredentials> <serviceAuthorization principalPermissionMode="Custom"> <authorizationPolicies> <add policyType="Asi.Soa.ServiceModelEx.ClaimsAuthorizationPolicy, Asi.Soa.ServiceModelEx" /> </authorizationPolicies> </serviceAuthorization> </behavior> </serviceBehaviors> </behaviors> 

Full exception stack trace:

 System.ServiceModel.Channels.ConnectionAcceptor..ctor(IConnectionListener listener, Int32 maxAccepts, Int32 maxPendingConnections, ConnectionAvailableCallback callback, ErrorCallback errorCallback) System.ServiceModel.Channels.ConnectionDemuxer..ctor(IConnectionListener listener, Int32 maxAccepts, Int32 maxPendingConnections, TimeSpan channelInitializationTimeout, TimeSpan idleTimeout, Int32 maxPooledConnections, TransportSettingsCallback transportSettingsCallback, SingletonPreambleDemuxCallback singletonPreambleCallback, ServerSessionPreambleDemuxCallback serverSessionPreambleCallback, ErrorCallback errorCallback) System.ServiceModel.Channels.SharedTcpTransportManager.CreateConnectionDemuxer() System.ServiceModel.Channels.SharedTcpTransportManager.OnDuplicatedVia(Uri via, Int32&amp; connectionBufferSize) System.ServiceModel.Channels.SharedConnectionListener.SharedListenerProxy.HandleOnVia(DuplicateContext duplicateContext) System.ServiceModel.Channels.SharedConnectionListener.SharedListenerProxy.System.ServiceModel.Activation.IConnectionDuplicator.BeginDuplicate(DuplicateContext duplicateContext, AsyncCallback callback, Object state) AsyncInvokeBeginBeginDuplicate(Object , Object[] , AsyncCallback , Object ) System.ServiceModel.Dispatcher.AsyncMethodInvoker.InvokeBegin(Object instance, Object[] inputs, AsyncCallback callback, Object state) System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc) System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Dispatch(MessageRpc&amp; rpc, Boolean isOperationContextSet) System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext) System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext) System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result) System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result) System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously) System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(IAsyncResult result) System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously) System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(Object state) System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state) System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback() System.ServiceModel.Channels.TracingConnection.WaitCallback(Object state) System.ServiceModel.Channels.PipeConnection.OnAsyncReadComplete(Boolean haveResult, Int32 error, Int32 numBytes) System.ServiceModel.Channels.OverlappedContext.CompleteCallback(UInt32 error, UInt32 numBytes, NativeOverlapped* nativeOverlapped) System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) 

Edit: I installed non-HTTP WCF activation components, launched ServiceModelReg.exe, added net.tcp and net.pipe to the list of allowed protocols in IIS Manager, etc. Not a joy.

I also wrote a Windows operating service to host the service (and not an ideal long-term solution for us), and the Net TCP connection works fine there, so it does not seem to be anything in my configuration or code, which means that something is wrong in IIS . Should the application pool for the application work in integrated mode? I tried this in both directions, it didn't seem to matter, but our application is currently installed in classic mode.

+4
source share
2 answers

As far as I can tell, the problem is that .NET does not like to host two services in the same IIS application, when one of them is the Soap11 endpoint and the other is the NetTcp endpoint. Removing the endpoint Soap11 allows the NetTcp endpoint to work without errors.

We moved on to the model where we use the Windows service to host the NetTcp endpoint and left the Soap11 endpoint in IIS.

If anyone finds out how to host the NetTcp and Soap11 service in the same application in IIS, I'd love to hear about it.

+2
source

Net.tcp does not work on IIS7 out of the box; there are a few things that need to be activated.

See: http://labs.episerver.com/en/Blogs/Paul-Smith/Dates/2008/6/Hosting-non-HTTP-based-WCF-applications-in-IIS7/

0
source

Source: https://habr.com/ru/post/1301471/


All Articles