簡體   English   中英

C#服務HTTP請求忽略自定義超時值

[英]C# Service HTTP Request ignoring custom timeout values

我有兩個應用程序一起工作。 第一個是與第二個服務進行通信的客戶端。 兩者都是用C#/。NET編寫的。

客戶端具有一個網頁,該網頁基於先前提交的數據(也在客戶端內)提交表單。

有問題的提交由服務處理。

在大多數情況下,提交都可以,但是在極少數情況下,可以處理許多(200+)個元素。 這是超時問題的出處。

在嘗試處理提交的地方設置try / catch塊會導致以下結果:

catching error: System.ServiceModel.FaultException 1[System.ServiceModel.ExceptionDetail]: The HTTP request to 'WSDL SERVICE HERE' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:

因此,我在客戶端和服務中都使用了Web.config文件,並使用以下設置binding標簽:

openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00"

奇怪的是,如果我將其設置為大於1分鍾的任何時間(特別是在客戶端中),則無法識別自定義值。 如果我將值設置為少於1分鍾,則可以識別自定義值。

我也玩過maxReceivedMessageSizemaxBufferSizemaxBufferPoolSize但無濟於事。

我真的不認為這與兩個應用程序中的邏輯都有關,好像元素計數為〜<100並不存在問題。 但是我們必須能夠處理200+個元素。

在兩個應用程序中都設置斷點有所幫助,但實際上並沒有幫助我。

任何見解對此表示贊賞。

將以下設置用於服務器和客戶端。 在我們的服務中,我們使用它來傳輸大量數據似乎對我們有用。

 <system.serviceModel> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> <bindings> <basicHttpBinding> <binding name="basicHttp" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Mtom" transferMode="Streamed"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> </binding> </basicHttpBinding> </bindings> <services> <service behaviorConfiguration="ServiceBehavior" name="MyService"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttp" name="MyService" bindingNamespace="CustomNameSpace" contract="IService"> <identity> <dns value="localhost" /> </identity> </endpoint> </service> </services> <behaviors> <endpointBehaviors> <behavior name="web"> <webHttp /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM