I got the Duplex Chat application (by Eugene) working on my remote hosting environment (not my local computer). But for some reason it only works across browsers in certain scenarios. I have gone through several scenarios of the duplex communication working
and not working. Using IE and Firefox, I tested the duplex functionality using separate browser windows on the same computer, as well as across 2 different computers. In the cases where it does not work, it may be working in one browser, but freezes up and
does not send out any message or connect to the service in the other browser. Here are my findings, please let me know if anyone has any ideas why it would not be working in some of these cases:
Works:
IE XP -- FF Vista (different machines)
FF Vista -- FF Vista (same machine)
IE XP -- IE XP (same machine)
IE Vista -- FF Vista (same machine)
Does Not Work:
IE XP -- IE Vista (different machines)
IE XP -- FF XP (same machine)
IE Vista -- IE Vista (same machine)
Interesting. I've not run into this problem myself, but I've implemented a heavily modified verison of Eugene's example. Perhaps he'll read this thread and take look into it.
Actually, I added a clientaccesspolicy.xml and crossdomain.xml file, and now the duplex works in every browser, just not ACROSS every browser. Some browsers will have their messages sync, while other browsers seem to create and share their own messages independently.
Furthermore, if I close out of all browsers for a while, and then try connecting to the duplex service again later, it appears to have frozen up, and will not let me even connect from any browser. I am really scratching my head here. Is your solution working
in a remote hosting environment ok? From Eugene's example, did you modify the "DuplexService.cs" or "DuplexReceiverSample.cs" class files at all (aside from their names)? I left these as they were, as they seemed to be generic, and only modified the files
that pertained to the "Chat" specifically for my usage.
I'm working in a shared-hosted environment right now.
I modified DuplexServiceFactory<T>() to make it compatible with my provider's hosting environment.
I heavily modified the actual web service class that derives from DuplexService. In my application I'm using Eugene's basic pattern to implement a client/server messaging service for my application (which is transparent to the user). But I am also supporting
with it a peer-to-peer messaging service, which includes chat capability. One significant thing I did add in the webservice class is a timeout mechanism for the "sessions". So if the service doesn't hear from a client within a period of time, it drops it
from the session list (in Eugene's example, that would be the chat client dictionary he maintains in the web service).
I'm not entirely satisfied with it yet. It has trouble with the same "user" connecting concurrent sessions. This problem can occur when the user closes the browser, then relaunches the application, effectively creating a new session, but the old session
has not yet timed out. I still haven't figured out a clean way to handle a cold disconnect like a browser close yet.... looking at Eugenes //TODO items in his example, it appears that he is still working this out as well.
Interesting, is there any way you could post (or send me) your implementation of the DuplexServiceFactory<T> and/or your modified web service class? Maybe this could help me get the duplex working on my remote hosting environment as well.
Also, what symptoms are you experiencing when the same "user" connects concurrent sessions? Are your messages still getting synchronized between the browsers properly? What other problems are you seeing here?
But I am having a strange issue. I have a static dictionary
object that maintains a list of all the active duplex clients. I have 2
Webservices A and B which consume this static dictionary object. Webservice A adds
a new callbackchannel to this dictionary
object while Webservice B uses this
dictionary to identify which all duplex clients a message needs to be sent.
What’s happening is when Webservice A is adding a duplex client to this dictionary, webservice B does not find
that Duplex client, it looks like we have 2 instances of a Dictionary. I tried
to use a Singleton Dictionary as well but with same fate. How we can create one
instance of dictionary object that can be used across multiple webservices.
Also on my local box I don’t see this issue as I run my App in VS 2010 which
uses its own web server. But once I deploy on the web server on IIS I see this
issue
Hi Prujohn..
referring to your statement..
"I tried to implement a model where each server-side instance would subscribe to an event, which when fired would then send a message to all of the service clients just fine."
I want to implement the above functionality.. please help me ..if you are having any demo code or link...please share...
thanks..
RobertDigital
Member
8 Points
4 Posts
Re: Another WCF polling/duplex question. How to send a "broadcast" message?
Nov 17, 2008 08:13 AM | LINK
Works:
IE XP -- FF Vista (different machines)
FF Vista -- FF Vista (same machine)
IE XP -- IE XP (same machine)
IE Vista -- FF Vista (same machine)
Does Not Work:
IE XP -- IE Vista (different machines)
IE XP -- FF XP (same machine)
IE Vista -- IE Vista (same machine)
prujohn
Contributor
3609 Points
713 Posts
Re: Another WCF polling/duplex question. How to send a "broadcast" message?
Nov 17, 2008 03:35 PM | LINK
Interesting. I've not run into this problem myself, but I've implemented a heavily modified verison of Eugene's example. Perhaps he'll read this thread and take look into it.
John
LUCA Studios
RobertDigital
Member
8 Points
4 Posts
Re: Another WCF polling/duplex question. How to send a "broadcast" message?
Nov 17, 2008 08:32 PM | LINK
prujohn
Contributor
3609 Points
713 Posts
Re: Another WCF polling/duplex question. How to send a "broadcast" message?
Nov 18, 2008 02:19 PM | LINK
I'm working in a shared-hosted environment right now.
I modified DuplexServiceFactory<T>() to make it compatible with my provider's hosting environment.
I heavily modified the actual web service class that derives from DuplexService. In my application I'm using Eugene's basic pattern to implement a client/server messaging service for my application (which is transparent to the user). But I am also supporting with it a peer-to-peer messaging service, which includes chat capability. One significant thing I did add in the webservice class is a timeout mechanism for the "sessions". So if the service doesn't hear from a client within a period of time, it drops it from the session list (in Eugene's example, that would be the chat client dictionary he maintains in the web service).
I'm not entirely satisfied with it yet. It has trouble with the same "user" connecting concurrent sessions. This problem can occur when the user closes the browser, then relaunches the application, effectively creating a new session, but the old session has not yet timed out. I still haven't figured out a clean way to handle a cold disconnect like a browser close yet.... looking at Eugenes //TODO items in his example, it appears that he is still working this out as well.
John
LUCA Studios
RobertDigital
Member
8 Points
4 Posts
Re: Another WCF polling/duplex question. How to send a "broadcast" message?
Nov 19, 2008 11:14 PM | LINK
Interesting, is there any way you could post (or send me) your implementation of the DuplexServiceFactory<T> and/or your modified web service class? Maybe this could help me get the duplex working on my remote hosting environment as well.
Also, what symptoms are you experiencing when the same "user" connects concurrent sessions? Are your messages still getting synchronized between the browsers properly? What other problems are you seeing here?
Thanks again,
Robert
jaspal.johar
Member
2 Points
1 Post
Re: Another WCF polling/duplex question. How to send a "broadcast" message?
Jul 29, 2011 07:47 PM | LINK
I think the if we send the message through Asynch it will prevent the hosing of the subsequesnt calls in the case of an inactive duplex client like:
public interface IDuplexClient
{
[OperationContract(IsOneWay = true, AsyncPattern = true)]
IAsyncResult BeginReceive(Message returnMessage, AsyncCallback callback, object state);
void EndReceive(IAsyncResult result);
}
and when sending the message back use the following code:
AsyncCallback handler = (asyncResult) =>
{
try
{
((IDuplexClient)(asyncResult.AsyncState)).EndReceive(asyncResult);
}
catch (Exception ex)
{
//;
}
};
callbackChannel.BeginReceive(message, handler, callbackChannel);
But I am having a strange issue. I have a static dictionary
object that maintains a list of all the active duplex clients. I have 2
Webservices A and B which consume this static dictionary object. Webservice A adds
a new callbackchannel to this dictionary
object while Webservice B uses this
dictionary to identify which all duplex clients a message needs to be sent.
What’s happening is when Webservice A is adding a duplex client to this dictionary, webservice B does not find
that Duplex client, it looks like we have 2 instances of a Dictionary. I tried
to use a Singleton Dictionary as well but with same fate. How we can create one
instance of dictionary object that can be used across multiple webservices.
Also on my local box I don’t see this issue as I run my App in VS 2010 which
uses its own web server. But once I deploy on the web server on IIS I see this
issue
Piyush Dixit
Member
2 Points
1 Post
Re: Another WCF polling/duplex question. How to send a "broadcast" message?
Jan 13, 2012 06:00 AM | LINK