WCF Net.TCP服务抛出模糊错误 [英] WCF Net.TCP service throwing obscure errors

查看:120
本文介绍了WCF Net.TCP服务抛出模糊错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为现有WCF服务启用附加的net.tcp端点(使用用户名身份验证).该服务托管在IIS7中.

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

针对服务执行客户端将返回套接字连接异常终止的错误.对服务启用跟踪会显示抛出以下异常:

Executing a client against the service returns an error that the socket connection was aborted. Enabling tracing against the service reveals the following exception is thrown:

System.ArgumentOutOfRangeException
此参数的值必须为正.
参数名称:maxAccepts
实际值为0.

System.ArgumentOutOfRangeException
The value of this argument must be positive.
Parameter name: maxAccepts
Actual value was 0.

我很困惑,因为尽我所能告诉我端口共享应该被配置禁用(见下文),但是它仍然通过端口共享代码进行调用(再次,我可以告诉我).无论如何,我找不到任何方法来指定此maxAccepts值. Google对此一无所知,并且maxPendingAccepts值似乎也没有.如何解决该错误?

I'm confused, because as best I can tell port sharing should be disabled by the configuration (see below), but it's still calling through the port sharing code (again, as best I can tell). In any case, I can't find any way to specify this maxAccepts value; Google doesn't know anything about it, and the maxPendingAccepts value doesn't seem to do it. How do I resolve the error?

该服务的配置文件包含net.tcp端点的以下内容:

The service's config 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>

完整的异常堆栈跟踪为:

The full exception stack trace is:

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)

我已经安装了非HTTP WCF激活组件,运行ServiceModelReg.exe,将net.tcp和net.pipe添加到IIS管理器中启用的协议列表中,等等.

I have installed the non-HTTP WCF activation components, run ServiceModelReg.exe, added net.tcp and net.pipe to the list of enabled protocols in IIS Manager, etc. No joy.

我还编写了一个快速的Windows服务来托管该服务(对于我们而言,这不是理想的长期解决方案),并且Net TCP连接在那里工作正常,因此在我的配置或代码,这意味着在IIS中不正确.该应用程序的应用程序池是否必须在集成模式下运行?我尝试了两种方式,似乎没有什么区别,但是我们的应用程序当前以经典模式安装.

I've also written a quick Windows Service to host the service (not the ideal long-term solution for us), and the Net TCP connection works fine there, so it doesn't appear to be anything in my configuration or code, which means something isn't right in/with IIS. Does the app pool for the application have to be running in Integrated mode? I tried it both ways, it didn't seem to make a difference, but our app currently is installed in Classic mode.

推荐答案

我能确定的唯一问题是,.NET不喜欢在同一个IIS应用程序中托管两个服务,而一个服务是Soap11终结点,而一个则是NetTcp端点.删除Soap11端点可使NetTcp端点正常工作.

As best I can determine, the problem is simply that .NET does not like hosting two services in the same IIS application when one is a Soap11 endpoint and one is a NetTcp endpoint. Removing the Soap11 endpoint allows the NetTcp endpoint to work without error.

我们已经转移到一个模型,在该模型中,我们使用Windows服务托管NetTcp终结点,并将Soap11终结点保留在IIS中.

We've moved to a model where we are using a Windows Service to host the NetTcp endpoint and left the Soap11 endpoint in IIS.

如果有人想出了如何在IIS的同一应用程序中同时托管NetTcp和Soap11服务,我很想听听它.

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

这篇关于WCF Net.TCP服务抛出模糊错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆