Yes, you can set the service timeout in web.config and you can set client timeout either with code or in ServiceReferences.ClientConfig, check a thread:
I want to restate my chat scenario, When user login it wil subscribe to chat service, on login a timer starts sending notification to all users for showing their online presence. Their presence is shown by an image (green circle). All the users are listed in a datagrid where one can also see the online users and start chatting by right clicking on the rows (user), context menu appears with relevant options. After chosing the chat option in the menu a chat window appears.
Basically, this chat window is user control called inside a Popup control. As soon as the constructor of the ChatWindow is called it will again create the instance of service proxy and will subscribe (basically we are not updating the channel here we are just updating list of chat session) and provide handler for the callback method. A thing to notice here is that whenever I am creating instance of client proxy I am first calling OpenAsync and then perform operations under its Complete event. I am not calling CloseAsync or Should I ?
The trace is not showing anything that I should be concern of. When the chat starts it is succefull from both ends, but as told that if I let chat windows open and stops chatting for a long time (15-20 min) and again starts chatting then it will just hung up. It seems that after commencing chat after 15 -20 min it does not sends any notification to the user. I don't know why ?
During this whole process did you find anything that concerns you, Please share I might get an idea on resolving this issue.
One more thing why the service should Timout I mean (I am not sure whether it is a cause of Timeout only) if the timer is running continuously.
public void Subscribe(int id, int toId, string fromWin, string toWin)
{
if (!this.user.ContainsKey(id))
this.user.GetOrAdd(id, OperationContext.Current.GetCallbackChannel<IChatNotification>());
//else if (this.user[id] != OperationContext.Current.GetCallbackChannel<IChatNotification>())
//this.user[id] = OperationContext.Current.GetCallbackChannel<IChatNotification>();
if (_Timer == null)
_Timer = new Timer(new TimerCallback(_Timer_Elapsed), null, 0, 500);
/*more*/
}
I encountered an error "The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state." Ths code block is here,
[OperationContract]
public List<int> OnlineUsers()
{
if (user != null)
{
List<KeyValuePair<int, Status>> list = GetStatusList(userStatus);
foreach (var k in user)
{
try
{
k.Value.UpdateAvailability(user.Select(x => x.Key).ToList(), list);
}
catch (TimeoutException ex)
{
}
}
}
return user.Select(x => x.Key).ToList();
}
This function is called by the Timer at each specified interval but after a long time it threw this exception. I have already set ReceiveTimeout and InactivityTimeout but I still got this error.
n00raina
Member
165 Points
120 Posts
Re: How can I increase the timeout in WCF polling application ?
Dec 15, 2012 08:41 AM|LINK
Ok, what I did in my Web.Config is this,
<pollingDuplexHttpBinding> <binding name="myPollingDuplexHttpBinding" duplexMode="MultipleMessagesPerPoll" inactivityTimeout="01:30:00" /> </pollingDuplexHttpBinding>and in my code where I connect to ChatService
client = new ChatServicePolling.ChatServiceClient( new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll) { InactivityTimeout = TimeSpan.FromHours(2), ReceiveTimeout = TimeSpan.FromHours(2), SendTimeout = TimeSpan.FromHours(2) }, new EndpointAddress("../ChatService.svc")); client.OpenAsync(client); client.OpenCompleted += client_OpenCompleted;But there is no change with application, still it stops responding after 10-15 minutes and there is no error fetched in Service log.
Haixia Xie -...
Contributor
3022 Points
294 Posts
Microsoft
Re: How can I increase the timeout in WCF polling application ?
Dec 18, 2012 08:47 AM|LINK
Hi,
Please enable tracing for the service to diagnose what is the exact issue.
Best Regards.
Feedback to us
Develop and promote your apps in Windows Store
n00raina
Member
165 Points
120 Posts
Re: How can I increase the timeout in WCF polling application ?
Dec 19, 2012 05:31 AM|LINK
Hi,
I have enabled tracing here,
<system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true"> <listeners> <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Web.svclog"/> </listeners> </source> </sources> </system.diagnostics>I want to restate my chat scenario, When user login it wil subscribe to chat service, on login a timer starts sending notification to all users for showing their online presence. Their presence is shown by an image (green circle). All the users are listed in a datagrid where one can also see the online users and start chatting by right clicking on the rows (user), context menu appears with relevant options. After chosing the chat option in the menu a chat window appears.
Basically, this chat window is user control called inside a Popup control. As soon as the constructor of the ChatWindow is called it will again create the instance of service proxy and will subscribe (basically we are not updating the channel here we are just updating list of chat session) and provide handler for the callback method. A thing to notice here is that whenever I am creating instance of client proxy I am first calling OpenAsync and then perform operations under its Complete event. I am not calling CloseAsync or Should I ?
The trace is not showing anything that I should be concern of. When the chat starts it is succefull from both ends, but as told that if I let chat windows open and stops chatting for a long time (15-20 min) and again starts chatting then it will just hung up. It seems that after commencing chat after 15 -20 min it does not sends any notification to the user. I don't know why ?
During this whole process did you find anything that concerns you, Please share I might get an idea on resolving this issue.
One more thing why the service should Timout I mean (I am not sure whether it is a cause of Timeout only) if the timer is running continuously.
public void Subscribe(int id, int toId, string fromWin, string toWin) { if (!this.user.ContainsKey(id)) this.user.GetOrAdd(id, OperationContext.Current.GetCallbackChannel<IChatNotification>()); //else if (this.user[id] != OperationContext.Current.GetCallbackChannel<IChatNotification>()) //this.user[id] = OperationContext.Current.GetCallbackChannel<IChatNotification>(); if (_Timer == null) _Timer = new Timer(new TimerCallback(_Timer_Elapsed), null, 0, 500); /*more*/ }n00raina
Member
165 Points
120 Posts
Re: How can I increase the timeout in WCF polling application ?
Dec 19, 2012 01:17 PM|LINK
Hi,
I encountered an error "The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state." Ths code block is here,
[OperationContract] public List<int> OnlineUsers() { if (user != null) { List<KeyValuePair<int, Status>> list = GetStatusList(userStatus); foreach (var k in user) { try { k.Value.UpdateAvailability(user.Select(x => x.Key).ToList(), list); } catch (TimeoutException ex) { } } } return user.Select(x => x.Key).ToList(); }This function is called by the Timer at each specified interval but after a long time it threw this exception. I have already set ReceiveTimeout and InactivityTimeout but I still got this error.