【问题标题】:ASP.NET MVC 3 WCF not working on load balancing serversASP.NET MVC 3 WCF 在负载平衡服务器上不起作用
【发布时间】:2012-06-18 19:39:02
【问题描述】:

我搜索了互联网,但找不到任何像我这样的场景。场景是我有一个 ASP.NET MVC 3 报告应用程序和独立的 WCF 托管服务。我正在为 ASP.NET MVC 3 进行 bin 部署。在我的本地环境和开发服务器上一切正常。我在 ASP.NET MVC 项目中使用服务引用来调用客户端代理。

但是,当我部署到负载平衡的客户端测试环境(ASP.NET 和 WCF 层都位于相同的负载平衡服务器上)时,它失败了。如果我运行本地构建并将端点指向他们的开发 wcf 服务,它工作正常。只有在尝试从测试 URL 本身启动应用程序时才会失败。我收到以下错误(编辑了端点和服务调用信息:

“System.ServiceModel.CommunicationException:发生错误时 接收对 http:[testserver] 的 HTTP 响应。这可能是由于 服务端点绑定不使用 HTTP 协议。这可以 也可能是由于服务器中止了 HTTP 请求上下文 (可能是由于服务关闭)。查看服务器日志了解更多信息 细节。 ---> System.Net.WebException:底层连接是 关闭:接收时发生意外错误。 ---> System.IO.IOException:无法从传输中读取数据 连接:已存在的连接被远程强行关闭 主持人。 ---> System.Net.Sockets.SocketException:现有连接 被远程主机强行关闭 System.Net.Sockets.NetworkStream.Read(Byte[] 缓冲区,Int32 偏移量, Int32 大小)---内部异常堆栈跟踪结束---在 System.Net.Sockets.NetworkStream.Read(Byte[] 缓冲区,Int32 偏移量, Int32 大小)在 System.Net.PooledStream.Read(Byte[] 缓冲区,Int32 偏移量,Int32 大小)在 System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) --- 结束 内部异常堆栈跟踪 --- 在 System.Net.HttpWebRequest.GetResponse() 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度 超时)---内部异常堆栈跟踪结束---服务器堆栈 追踪:在 System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest 请求, HttpAbortReason abortReason) 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度 超时)在 System.ServiceModel.Channels.RequestChannel.Request(消息消息, TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串动作, Boolean oneway, ProxyOperationRuntime 操作, Object[] ins, Object[] 出局,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime 操作)在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)在 [0] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(消息数据& msgData,Int32 类型)在 ReportingApp.UserClientProxy.IUser.GetUsersBetween(日期时间开始, 日期时间结束)在 ReportingApp.Controllers.HomeController.PopulateResultsTable(ReportingViewModel vm) 在 ReportingApp.Controllers.HomeController.Index() 在 lambda_method(闭包,ControllerBase,对象[])在 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext 控制器上下文,IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 参数)在 System.Web.Mvc.ControllerActionInvoker.c_DisplayClass15.b_12() 在 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter 过滤器,ActionExecutingContext preContext,Func1 continuation) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 过滤器,ActionDescriptor actionDescriptor, IDictionary`2 参数)在 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)"

我的 ASP.NET wcf 配置如下:

<bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IUser" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="5242880" maxBufferPoolSize="5242880" maxReceivedMessageSize="5242880"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="5242880" maxStringContentLength="5242880" maxArrayLength="5242880"
            maxBytesPerRead="5242880" maxNameTableCharCount="5242880" />
          <security mode="None" >
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
            <message clientCredentialType="UserName"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="[testEndPoint]" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IUser" contract="UserClientProxy.IUser"
        name="BasicHttpBinding_IUser" />

我的服务网络配置如下所示:

 <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <!--Doubled from value again to resolve issues with the reporting process.-->
          <dataContractSerializer maxItemsInObjectGraph="524288" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding maxBufferSize="5242880" maxBufferPoolSize="5242880" maxReceivedMessageSize="5242880">
          <readerQuotas maxDepth="5242880" maxStringContentLength="5242880" maxArrayLength="5242880"
           maxBytesPerRead="5242880" maxNameTableCharCount="5242880" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

知道是什么导致了这个问题吗?可能是权限问题还是配置问题?我很困惑,因为它从我的本地构建指向客户端测试环境端点。

提前谢谢你!

【问题讨论】:

  • 我在想,你的意思是你有你的 web 服务 web 配置和你的 asp.net MVC web 配置?而不是 asp.net WCF 配置?
  • 你在哪里定义你的服务端点?
  • 嗨 Edmund,是的,我有我的 asp.net mvc 网络配置和我的网络服务网络配置。我的端点实际上指向 DNS 服务器名称。我在想这可能是防火墙或 DNS 将服务调用重新路由到另一个服务。
  • 你的负载均衡器对连接做了奇怪的事情,这就是你得到通信异常的原因。这可能完全取决于您的负载均衡器的具体情况,并且可能无法在 SO 上解决。您可能可以获得有关 serverfault 负载均衡器的帮助。老实说,您可能需要负载平衡器供应商的供应商支持。

标签: asp.net asp.net-mvc-3 wcf load-balancing


【解决方案1】:

我知道这个答案已经晚了,但是我的 Rest 服务也遇到了类似的问题,它们在我们的开发服务器上运行良好,然后当我们将它们部署到负载平衡池并调用另一个服务时它们停止工作这也在负载平衡池上。

打开源地址转换后,我们就可以开始工作了。我们的 Web 管理员不得不将 F5 池中的 Translation 设置更改为 SNAT 池。此链接为您的网络人员提供了更多信息。

https://support.f5.com/kb/en-us/products/lc_9_x/manuals/product/lc_config_guide_10_1/lc_addrtrans.html

因此,当服务正常工作,现在调用负载平衡的东西时失败时,这可能会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 2011-12-27
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    相关资源
    最近更新 更多