Silverlight 4 Ria服务超时问题 [英] Silverlight 4 Ria Services Timeout Issues
问题描述
我正在从Silverlight客户端向DomainService进行呼叫,通常需要大约2分钟。为了安全起见,我需要将端点的超时值延长到5分钟,但它似乎忽略了该设置,因此我找不到原因。这是我在客户端中创建DomainContext的方式:
I am making a call from my Silverlight client into my DomainService that normally takes about 2 minutes. I need to extend the timeout value of the endpoint to 5 minutes to be safe, but it appears to ignore the setting and I can't find out why. Here is how I am creating my DomainContext in my client:
MyDomainContext context = new MyDomainContext();
((WebDomainClient<MyDomainContext.IMyDomainServiceContract>)context.DomainClient).ChannelFactory.Endpoint.Binding.ReceiveTimeout = new TimeSpan(0, 5, 0);
context.Search(_myParms, p =>
{
if (p.HasError)
{
// Handle errors
}
// Should take about 2 min. to get here, but times out before
}, null);
我尝试同时设置ReveiveTimeout和SendTimeout,但是我总是在1分钟时收到错误消息。
I have tried setting the ReveiveTimeout and SendTimeout both, but I always get the error at exactly 1 minute.
有人可以告诉我我在做什么错吗?
Can someone tell me what I am doing wrong?
编辑:这是我得到的确切错误:
This is the exact error I am getting:
{System.Net.WebException:远程服务器返回错误:NotFound。 ---> System.Net.WebException:远程服务器返回错误:NotFound。 System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)的
System.Net.Browser.BrowserHttpWebRequest的
。<> c_ DisplayClass5.b _4(对象sendState)
在System.Net.Browser.AsyncHelper。<> c_ DisplayClass2.b _0(Object sendState)
-内部异常堆栈跟踪的结尾-
在System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,对象状态)
在System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
在System.ServiceModel.Channels.HttpChannelFactory。 HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)}
{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_DisplayClass5.b_4(Object sendState) at System.Net.Browser.AsyncHelper.<>c_DisplayClass2.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)}
我也进行了测试,以确保它不在我的服务中。目前,我只是让我的服务运行while循环。再次,我恰好在一分钟内收到此错误。
I have also tested to make sure it's not something in my service. At present, I just have my service run a while loop. Again, I get this error at exactly one minute.
谢谢,
-Scott
推荐答案
您应该实现MyDomainContex类的部分方法OnCreated()。
You should implement partial method OnCreated() of MyDomainContex class.
示例:
public partial class TestDomainContext
{
partial void OnCreated()
{
var proxy = (WebDomainClient<Test.Server.Services.TestDomainContext.ITestDomainServiceContract>)this.DomainClient;
proxy.ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);
}
这篇关于Silverlight 4 Ria服务超时问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!