【问题标题】:WCF Net.TCP service throwing obscure errorsWCF Net.TCP 服务抛出模糊错误
【发布时间】:2011-01-17 12:47:33
【问题描述】:

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

针对服务执行客户端会返回套接字连接已中止的错误。启用对服务的跟踪显示引发了以下异常:

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

我很困惑,因为我尽我所能告诉配置应该禁用端口共享(见下文),但它仍然通过端口共享代码调用(再次,据我所知)。无论如何,我找不到任何方法来指定这个 maxAccepts 值;谷歌对此一无所知,并且 maxPendingAccepts 值似乎没有这样做。如何解决错误?

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

<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>

完整的异常堆栈跟踪是:

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 管理器中启用的协议列表等。不高兴。

我还编写了一个快速的 Windows 服务来托管该服务(对我们来说不是理想的长期解决方案),并且 Net TCP 连接在那里工作正常,所以它似乎不是我的配置中的任何内容或代码,这意味着在 IIS 中/使用 IIS 时某些内容不正确。应用程序的应用程序池是否必须在集成模式下运行?两种方式我都试过了,似乎没有什么不同,但我们的应用目前安装在经典模式下。

【问题讨论】:

    标签: wcf net.tcp


    【解决方案1】:

    据我所知,问题只是当一个是 Soap11 端点和一个是 NetTcp 端点时,.NET 不喜欢在同一个 IIS 应用程序中托管两个服务。删除 Soap11 端点允许 NetTcp 端点正常工作。

    我们已经转移到使用 Windows 服务托管 NetTcp 端点并将 Soap11 端点留在 IIS 中的模型。

    如果有人知道如何在 IIS 的同一个应用程序中同时托管 NetTcp 和 Soap11 服务,我很想听听。

    【讨论】:

    • 同一个 IIS 主机中的 SOAP 端点和 net.pipe 端点似乎也有问题。
    【解决方案2】:

    Net.tcp 在 IIS7 开箱即用时不起作用,有很多东西需要激活。

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

    【讨论】:

    • 不幸的是,我已经完成了该文章中列出的所有操作,但仍然出现错误。
    猜你喜欢
    • 2011-12-31
    • 1970-01-01
    • 2011-10-15
    • 1970-01-01
    • 2016-03-21
    • 2012-05-26
    • 2016-04-10
    • 2015-04-22
    • 2011-10-01
    相关资源
    最近更新 更多