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& 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& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Dispatch(MessageRpc& 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.