On Wed, Oct 13, 2010 at 07:18, razor <ryann...@gmail.com> wrote:
> Has anyone successfully figured out a way if to disconnect a user from
> the comet server when they navigate away from a page?
>
> The issue im having with is that when a user (lets say user-a) leaves
> a chat room, all other users that are connected to that chat room has
> no way of knowing that user-a has left.
You can register a remove listener.
When the server expires user-a, you can send a message on the
membership channel, so all other users are notified that user-a left.
What CometD version ?
Simon
--
http://bordet.blogspot.com
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless. Victoria Livschitz
On Wed, Oct 13, 2010 at 09:54, razor <ryann...@gmail.com> wrote:
> Hi Simon,
>
> Thanks for the response.
>
> Im currently using CometD 2.0 / jQuery and jetty7
>
> Do i register removeListener right after "addListener" as it's written
> the documentation (http://cometd.org/documentation/cometd-javascript/
> subscription) ? Im a bit confused on how this function should
> behave. I assumed 'removeListener' is to be called if you no longer
> would like to listen to any of the subscribed events.
No, a RemoveListener is a listener that gets called when the session expires.
That method is called once when the sessions first register to the
chat room, and adds a RemoveListener to the session so that when it
expires it broadcast the members to other sessions.
Simon
--
--
You received this message because you are subscribed to the Google Groups "cometd-users" group.
To post to this group, send email to cometd...@googlegroups.com
To unsubscribe from this group, send email to cometd-users...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cometd-users
Visit the CometD website at http://www.cometd.org
On Wed, Feb 16, 2011 at 12:31, agi <agim...@gmail.com> wrote:
> Hello everyone,
>
> I am also having problems with the client disconnect and I am hope you
> can help me out.:) I am using dojo 1.5.0 and CometD 1.1.1 on GlassFish
> and Oracle Weblogic 10.2 (the cometd implementation is wrapped with
> the atmosphere framework which enables it to run on any java server).
I do not think you need to wrap CometD into atmosphere as we have
reports working in GlassFish without it.
Anyway, if it works for you, fine.
> I have a BayeuxService that adds a RemoveListener to each client in my
> web application. The RemoveListener cleans up the client associated
> server side data when a client is removed/disconnected but the problem
> is that it doesn't get fired because the server obviously doesn't seem
> to be able to detect a disconnected client.
The server is able to detect a disconnected client, either by
receiving a disconnect message or by expiring clients it does not see
in a while after a configurable timeout.
> It gets triggered OK when
> I call dojox.cometd.disconnect(); from javascript on the page but it
> doesn't work when I put it in a window.onunload handler like that:
> window.onunload = function() {
> dojox.cometd.disconnect();
> }
First, are you sure that the onunload function is called at all ? I
ask because often browsers are buggy on this.
Even if it's called, it's upon the browser to decide if allow further
HTTP requests (the disconnect message) from a page the browser knows
it will be dismissed.
I do not think there is a clear specification about unload handlers
(what they can do and what they cannot), but I'll be glad to read it
if anyone has a pointer.
You can try a synchronous disconnect by calling:
window.onunload = function() {
dojox.cometd.disconnect(true);
}
but that's only a hint, since it's not supported by certain transports
and the browser can still ignore it.
See http://bugs.cometd.org/browse/COMETD-67 and
http://bugs.cometd.org/browse/COMETD-186 for further discussion.
While it's ok to attempt to disconnect gracefully, the server side
application code should not expect it but rely on the expiration that
will kick in after the timeout.
On Wed, Feb 16, 2011 at 14:15, agi <agim...@gmail.com> wrote:
> I know CometD works on GlassFish out of the box, I am not using
> atmosphere just for fun.:) It is because it enables me to setup my web
> application and deploy it on Glassfish and Weblogic without any
> modifications. For testing purposes I use GlassFish but we use
> Weblogic in a production environment, so such a wrapper framework is a
> necessity.
Oh, ok. So it's needed by WebLogic ?
I seems to recall having others using WebLogic without Atmosphere, but
as I said, fine.
It's just for the record in case someone browses the mail archives.
>> The server is able to detect a disconnected client, either by
>> receiving a disconnect message or by expiring clients it does not see
>> in a while after a configurable timeout.
>
> That doesn't seem to be true in my case. Which parameters should I use
> to configure such behaviour? At the moment am using the following init
> parameters in web.xml:
> <init-param>
> <param-name>timeout</param-name>
> <param-value>60000</param-value>
> </init-param>
> <init-param>
> <param-name>maxInterval</param-name>
> <param-value>10000</param-value>
> </init-param>
It's "maxInterval", here at 10 seconds.
After 10 seconds that a connect is not seen from a client, the server
expires the client (10 seconds + the sweeper delay, which is at most 2
seconds IIRC).
> Exactly when should a client be automatically disconnected/removed?
> "maxInterval" ms after the timeout (in my case 10s after an
> unsuccessful reconnect)?
Correct.
> Maybe the automatic client removal isn't
> working because of a problem with the atmosphere framework, I will ask
> the guys a atmosphere about that...
Let us know if that's the case.
On Wed, Feb 16, 2011 at 15:54, agi <agim...@gmail.com> wrote:
> However I still have to resolve the issue regarding the broken
> detection of disconnected clients on the server...
Be sure on server side you have a System.out that prints when a
Session is removed (need to implement ServerSession.RemoveListener),
then open your application in Firefox, allow CometD to connect, then
click File/Work Offline.
Go to the server console and wait for the printout after maxInterval.
Please upgrade to CometD 1.1.3, and see if the problem remains.
If so, then please file a bug at http://bugs.cometd.org with the
reproducible test case attached with exact steps to reproduce the
problem.
Could it be that the servlet container that you're using is not Jetty,
and that it is a buggy or misconfigured one ?
On Fri, Feb 18, 2011 at 13:35, agi <agim...@gmail.com> wrote:
> I am using GlassFish v3.
What precise version ?
GF was known to have bugs in handling asynchronous requests.
Please search the lists archives for others that had problems and
reported that certain GF version actually worked fine.