我們最近更換了代碼庫,以編程方式設置WCF綁定並生成代理。我們已經開始在ServiceReferences.clientconfig中定義配置。從那以後,一些長期的WCF調用已經在Silverlight中超時了,我不知道爲什麼。我已將綁定中的所有超時設置爲24小時。我需要一些關於如何診斷問題的建議。Silverlight WCF超時
起初我以爲問題是客戶端的超時,因爲錯誤發生幾分鐘後,但服務器端的代碼繼續,並最終成功完成。但我現在還不完全確定這一點。我正在觀看Kestrel日誌窗口,並注意到它表示在Silverlight中彈出錯誤的同時,即使操作在服務器端繼續,請求也完成了。但是,我無法找到有關在服務器端設置OperationTimeout的任何信息。下面是在服務器端綁定:
private static CustomBinding CreateCustomBinding()
{
var httpTransportBindingElement = new HttpTransportBindingElement
{
MaxBufferPoolSize = 2147483647,
MaxBufferSize = 2147483647,
MaxReceivedMessageSize = 2147483647
};
var bindingElements = new BindingElementCollection();
var binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement
{
MaxReadPoolSize = 2147483647,
MaxSessionSize = 2147483647,
MaxWritePoolSize = 2147483647,
ReaderQuotas = new XmlDictionaryReaderQuotas
{
MaxDepth = 2147483647,
MaxStringContentLength = 2147483647,
MaxArrayLength = 2147483647,
MaxBytesPerRead = 2147483647,
MaxNameTableCharCount = 2147483647
}
};
bindingElements.Add(binaryMessageEncodingBindingElement);
bindingElements.Add(httpTransportBindingElement);
var binding = new CustomBinding(bindingElements)
{
Name = "UserNameBinding",
CloseTimeout = new TimeSpan(24, 0, 0),
OpenTimeout = new TimeSpan(24, 0, 0),
ReceiveTimeout = new TimeSpan(24, 0, 0),
SendTimeout = new TimeSpan(24, 0, 0)
};
return binding;
}
下面是如何在客戶端創建綁定的代碼。讓我知道是否有任何其他代碼在這裏相關,我錯過了。我已經調試了這段代碼,以確保代理獲取綁定集。
public static Binding GetWCFBinding(bool isHttps)
{
var binding = new CustomBinding
{
CloseTimeout = new TimeSpan(24, 00, 00),
OpenTimeout = new TimeSpan(24, 00, 00),
ReceiveTimeout = new TimeSpan(24, 00, 00),
SendTimeout = new TimeSpan(24, 00, 00)
};
var binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement();
binding.Elements.Add(binaryMessageEncodingBindingElement);
binding.Elements.Add(isHttps
? new HttpsTransportBindingElement()
{
MaxBufferSize = int.MaxValue,
MaxReceivedMessageSize = int.MaxValue,
TransferMode = TransferMode.Buffered
}
: new HttpTransportBindingElement()
{
MaxBufferSize = int.MaxValue,
MaxReceivedMessageSize = int.MaxValue,
TransferMode = TransferMode.Buffered
});
return binding;
}
我也把這個線在代理的構造函數:
InnerChannel.OperationTimeout =新的時間跨度(24,0,0);
的錯誤是這樣的非描述錯誤時,出現錯誤的服務器或客戶機超時,它總是返回:
Module: Adapt.Presentation.Xivic.CodeGeneration Exception Message: The remote server returned an error: NotFound. Time: 6/03/2017 4:17:55 PM Stack Trace: ThrowForNonSuccess at offset 90 in file:line:column :0:0 HandleNonSuccess at offset 87 in file:line:column :0:0 GetResult at offset 30 in file:line:column :0:0 MoveNext at offset 525 in file:line:column :0:0 Full Exception: System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.b__9(Object sendState) at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.b__0(Object sendState) --- End of inner exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) --- End of inner exception stack trace --- at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) at Microsoft.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Adapt.Presentation.Xivic.CodeGeneration.d__15.MoveNext()