Azure Cloud Service上的WCF间歇性地返回http错误503

时间:2015-08-21 18:52:45

标签: wcf iis-8 http-proxy azure-cloud-services http-status-code-503

我们有一个安装了WCF作为Web角色的Azure云服务。该服务使用实体框架在线连接到azure db。该服务由WPF客户端使用,该客户端使用公司代理连接到Web。

有时客户收到错误:"服务器太忙了。" ,内部异常是" HTTP 503 - 服务不可用"。

为了调查此错误,我尝试通过远程桌面连接云服务的VM:

  1. 事件查看器:"应用程序"中没有应用程序池崩溃或错误的迹象并且在" System"部分。
  2. FREB日志(已激活规则):未记录任何内容。
  3. HTTPerr日志:无失败请求的跟踪。
  4. 我已激活WCF内部TraceLog。日志正确跟踪信息,但没有记录异常或错误。
  5. 在IIS上我改变了:

    • 来自" ondemand"的应用程序池到"总是跑步"
    • 队列限制
    • 禁用快速失效保护(仅供测试)
    • 更改了应用程序池标识

    我还向WCF添加了遥测功能,以记录所有异常和一些请求。 没有任何帮助,错误继续随机出现。

    今天我在托管WCF的服务器上安装了WireShark并捕获了入站流量。 即使没有响应代码请求失败的迹象!= 200,所有请求都是" http1.1 200 OK。"

    前几天我在家工作并经常使用WPF客户端(不使用代理),错误从未出现过。

    可能与我们在工作中使用的公司代理相关吗?

    在客户端和WCF配置下面:

    WPF客户端配置:

     <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <configSections>
      </configSections>
    
      <appSettings>
        <add key="ClientSettingsProvider.ServiceUri" value="" />
      </appSettings>
      </connectionStrings>
      </entityFramework>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
      </startup>
      <system.serviceModel>
        <bindings>
          <customBinding>
            <binding name="largedata"  closeTimeout="00:21:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00">
              <security  authenticationMode="UserNameOverTransport" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" allowInsecureTransport="true" />
              <binaryMessageEncoding  maxReadPoolSize="2147483647" maxWritePoolSize="2147483647" compressionFormat="GZip">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              </binaryMessageEncoding>
              <httpTransport  bypassProxyOnLocal="True"
                              authenticationScheme="Basic"
                              useDefaultWebProxy="True" 
                              proxyAuthenticationScheme="Basic" 
                              keepAliveEnabled="True" 
                              maxBufferPoolSize="2147483647"
                              maxReceivedMessageSize="2147483647"
                              maxBufferSize="2147483647" />
            </binding>
          </customBinding>
        </bindings>
        <client>
          <endpoint address="http://wcfadress/Data.svc" binding="customBinding" bindingConfiguration="largedata" contract="DataService.DataService" name="largedata" />
        </client>                       
      </system.serviceModel>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <system.net>
        <defaultProxy enabled="true" useDefaultCredentials="true">
          <proxy proxyaddress="http://proxyadress" ></proxy>
        </defaultProxy>
            <settings>
          <servicePointManager expect100Continue="false" />
        </settings>
      </system.net>
      <system.web>
        <membership defaultProvider="ClientAuthenticationMembershipProvider">
          <providers>
            <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
          </providers>
        </membership>
        <roleManager defaultProvider="ClientRoleProvider" enabled="true">
          <providers>
            <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
          </providers>
        </roleManager>
      </system.web>
    </configuration>
    

    WCF配置

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
    <system.diagnostics>
        <trace>
            <listeners>
                <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
                    <filter type="" />
                </add>
            </listeners>
        </trace>
      <sources>
          <source name="System.ServiceModel" switchValue="Critical, Error, Warning" propagateActivity="true">
            <listeners>
              <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\temp\TracesWCF.svclog" />
            </listeners>
          </source>
        </sources>
    </system.diagnostics>
    <connectionStrings>
      <add name="Clio" providerName="System.Data.EntityClient" connectionString="metadata=res://*/DataMadel.csdl|res://*/DataMadel.ssdl|res://*/DataMadel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=*****;Initial Catalog=*****;Language=Italian;Integrated Security=False;*****;Password=*****;Connection Timeout=600;MultipleActiveResultSets=True;Encrypt=True;Min Pool Size=20;Max Pool Size=50;TrustServerCertificate=False&quot;" />
      </connectionStrings>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
      </entityFramework>
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
       <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" maxRequestLength="202400" />
        <httpModules>
          <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" />
        </httpModules>
      </system.web>
      <system.serviceModel>
         <diagnostics>
          <messageLogging
                  logEntireMessage="true"
                  logMalformedMessages="false"
                  logMessagesAtServiceLevel="true"
                  logMessagesAtTransportLevel="true"
                  maxMessagesToLog="400"
                  maxSizeOfMessageToLog="6000"/>
        </diagnostics>
        <bindings>
           <customBinding>
            <binding name="largedata" closeTimeout="00:21:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:50:00">
                 <security authenticationMode="UserNameOverTransport" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" allowInsecureTransport="true" />
              <binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647" compressionFormat="GZip">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              </binaryMessageEncoding>
              <httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
            </binding>
          </customBinding>
        </bindings>
        <services>
          <service name="ArchivioStorico.Service.DataService" behaviorConfiguration="Auth">
            <endpoint address="" binding="customBinding" bindingConfiguration="largedata" contract="ArchivioStorico.Service.DataService" />
            <endpoint address="basicHttp" binding="basicHttpBinding" contract="ArchivioStorico.Service.DataService" />
          </service>
         </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="Auth">
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true" />
              <dataContractSerializer maxItemsInObjectGraph="2147483647" />
              <serviceThrottling maxConcurrentCalls="1300" maxConcurrentSessions="1300" maxConcurrentInstances="1300"></serviceThrottling>
              <serviceCredentials>
                <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="ArchivioStorico.Service.CustomValidator.CustomUserNameValidator, App_Code" />
              </serviceCredentials>
            </behavior>   
    
           </serviceBehaviors>
          <endpointBehaviors>
            <behavior>
              <dataContractSerializer maxItemsInObjectGraph="2147483647" />
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <protocolMapping>
          <add binding="basicHttpsBinding" scheme="https" />
          <add binding="basicHttpBinding" scheme="http" />
          <add binding="webHttpBinding" scheme="http" />
        </protocolMapping>    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
          <remove name="ApplicationInsightsWebTracking" />
          <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" preCondition="managedHandler" />
        </modules>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true" />
        <security>
          <requestFiltering>
            <!--Increase 'maxAllowedContentLength' to needed value: 100mb (value is in bytes)-->
            <requestLimits maxAllowedContentLength="204857600" />
          </requestFiltering>
        </security>
        <validation validateIntegratedModeConfiguration="false" />
      </system.webServer>
    
      <runtime>
    
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    
          <dependentAssembly>
    
            <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    
            <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
    
          </dependentAssembly>
    
          <dependentAssembly>
    
            <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    
            <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
    
          </dependentAssembly>
    
          <dependentAssembly>
    
            <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    
            <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
    
          </dependentAssembly>
    
        </assemblyBinding>
    
      </runtime>
      <system.net>
        <settings>
          <servicePointManager expect100Continue="false" />
        </settings>
      </system.net>
    </configuration>
    

0 个答案:

没有答案