[英]Silverlight WCF Timeout
我们最近将代码库切换为以编程方式设置WCF绑定并生成代理。 我们已经不再在ServiceReferences.clientconfig中定义配置了。 从那以后,一些较长的WCF调用在Silverlight中超时了,我不知道为什么。 我已将绑定中的所有超时设置为24小时。 我需要一些有关如何诊断问题的建议。
起初,我认为问题是客户端超时,因为错误是在几分钟后发生的,但是服务器端的代码仍在继续,并最终成功完成。 但是我现在还不确定。 我正在查看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 = new TimeSpan(24,0,0);
该错误是此非描述性错误,当服务器上发生问题或客户端超时时总是返回:
模块:Adapt.Presentation.Xivic.CodeGeneration异常消息:远程服务器返回错误:未找到。 时间:6/03/2017 4:17:55 PM堆栈跟踪:ThrowForNonSuccess在文件中的偏移量90处:行:列:0:0 HandleNonSuccess在文件中的偏移量87处:行:列:0:0 GetResult在文件中的偏移量30处:line:column:0:0 MoveNext在file:line:column:0:0的偏移525处完全异常:System.ServiceModel.CommunicationException:远程服务器返回错误:NotFound。 ---> System.Net.WebException:远程服务器返回错误:NotFound。 ---> System.Net.WebException:远程服务器返回错误:NotFound。 在System.Net.Browser.BrowserHttpWebRequest的System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult)处。在System.Net.Browser.AsyncHelper。<> c__DisplayClassa.b__9(Object sendState)处。 -内部异常堆栈跟踪的结尾--在System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)在System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,Object state)在System.ServiceModel.Channels。 HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult结果)-内部异常堆栈跟踪结束--在Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)在Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(任务任务) )在Microsoft.Runtime.CompilerServices.TaskAwaiter`1.GetResult()在Adapt.Presentation.Xivic.CodeGeneration.d__15.MoveNext()
由于您使用的是Silverlight,因此很可能是DomainService
not found错误。 这是相当普遍的问题,指向服务器上的错误配置。 您应该能够启动Fiddler并查看失败的URL,并将其与服务器端的先前版本进行比较。
只是快速浏览您的绑定,我看不到为您的服务定义的端点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.