2012-12-10 94 views
1

增加緩衝區大小,我得到這個錯誤://localhost:4936/UserService.svc:在接收到http HTTP響應發生WCF如何在Metro應用程序(客戶端)

錯誤。這可能是由於服務端點綁定不使用HTTP協議。這也可能是由於HTTP請求上下文被服務器中止(可能是由於服務關閉)。查看服務器日誌獲取更多詳細信

內部異常: 無法讀取傳輸連接的數據:一個現有的連接被強行遠程主機

這裏關閉是我的web.config(服務層):

<?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> 
    <connectionStrings> 
    <add name="DellenyEntities" connectionString="metadata=res://*/DellenyModel.csdl|res://*/DellenyModel.ssdl|res://*/DellenyModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=Delleny;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    <add name="DellenyModelContainer" connectionString="metadata=res://*/DellenyModel.csdl|res://*/DellenyModel.ssdl|res://*/DellenyModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=Delleny;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="v11.0" /> 
     </parameters> 
    </defaultConnectionFactory> 
    </entityFramework> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5"/> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicBinding" 
       maxBufferPoolSize="1500000" 
       maxReceivedMessageSize="1500000" 
       maxBufferSize="1500000"> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- 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"/> 

     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service name="Delleny.Services.UserService"> 
     <endpoint binding="basicHttpBinding" bindingConfiguration="BasicBinding" 
        contract="Delleny.Model.IUserService" /> 
     </service> 
     <service name="Delleny.Services.BCService"> 
     <endpoint binding="basicHttpBinding" bindingConfiguration="BasicBinding" 
        contract="Delleny.Model.IBCService" /> 
     </service> 
    </services> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <!-- 
     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"/> 
    </system.webServer> 

</configuration> 
+0

深入鑽取錯誤的最佳方法是啓用跟蹤(http://msdn.microso ft.com/en-us/library/ms733025.aspx)上查看您的服務,並查看您爲何得到該錯誤的確切原因。這可能是由於您的服務發送或接收的數據量所致。在客戶端和服務器端增加您的readerQuotas – Rajesh

+0

這正是錯誤..如何增加客戶端和服務器端的讀取器配額? –

+0

查看下面文章... – Rajesh

回答

0

剛用下面所示的東西替換您的綁定元素:

<binding name="BasicBinding" maxReceivedMessageSize="2000000" maxBufferSize="2000000" transferMode="Streamed"> 
    <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" /> 
</binding> 
+0

我添加了這段代碼,但我仍然得到相同的錯誤,感謝您的幫助 –

+0

什麼是約。服務發送/接收的數據大小?還要考慮增加serviceBehaviour中的maxItemsInObjectGraph。如果大小超過4MB,請考慮增加httpRunTime maxRequestLength – Rajesh

相關問題