[JIRA] (COMETD-366) Messages not received on channel regulat after async handshake on META channel

16 views
Skip to first unread message

akram (Created) (JIRA)

unread,
Apr 24, 2012, 8:14:25 PM4/24/12
to comet...@googlegroups.com
Messages not received on channel regulat after async handshake on META channel
------------------------------------------------------------------------------

Key: COMETD-366
URL: http://bugs.cometd.org/browse/COMETD-366
Project: CometD
Issue Type: Bug
Components: java-client
Affects Versions: 2.4.1, 2.4.0, 2.4.0.beta1
Reporter: akram
Priority: Blocker


While subscribing to a channel after having handshaken successfully in an asynchronous way, messages are never received on the channel.

This is not the case when synchronous (.waitFor(10000, State.CONNECTED)) handshake is used.
I am reusing the same LongPollingTransport for both subscription. I am using a customized transport that adds authentication header to the Exchange object.

Here are some code Snippets:
httpClient = new HttpClient();
httpClient.start();
Map<String, Object> options = new HashMap<String, Object>();
ClientTransport transport = new MyLongPollingTransport(options, httpClient);
client = new BayeuxClient(Configuration.getServerURL() + COMET_PUBLISH_URI, transport);
ClientSessionChannel channel = client.getChannel(Channel.META_HANDSHAKE);
EventProcessor eventProcessor = new EventProcessor();
ClientSessionChannelListener handshakeListener = new HandshakeSuccesfulListener(eventProcessor, listener);
channel.addListener(handshakeListener);
client.handshake();

Then in the HandshakeSuccesfulListener.onMessage() method:
if (message.isSuccessful()) {
ClientSessionChannel push = channel.getSession().getChannel(COMET_SUBSCRIBE_URI + "/" + Configuration.getUsername());
push.subscribe(listener);
// push.addListener(listener); Tried this one with no difference
eventProcessor.init();

LOGGER.info("Handshake successful sur le channel {}", channel);
while ( !interrupted) {
eventProcessor.process();
}
}

While events are successfully posted on server side, they are never received on the channel.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: http://bugs.cometd.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Simone Bordet (Resolved) (JIRA)

unread,
Apr 26, 2012, 7:50:25 AM4/26/12
to comet...@googlegroups.com

[ http://bugs.cometd.org/browse/COMETD-366?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Simone Bordet resolved COMETD-366.
----------------------------------

Assignee: Simone Bordet
Fix Version/s: 2.4.1
Resolution: Not a Bug

Listeners must be quick to execute and return as soon as possible.

In your code example, you have an infinite loop inside the listener, which never returns and basically blocks the whole CometD processing.

You should run your EventProcessor in a separate thread, if you really need so, and pass the messages to it from the listener.

> Messages not received on regular channel after asynchronous handshake on META channel
> --------------------------------------------------------------------------------------
>
> Key: COMETD-366
> URL: http://bugs.cometd.org/browse/COMETD-366
> Project: CometD
> Issue Type: Bug
> Components: java-client
> Affects Versions: 2.4.0.beta1, 2.4.0, 2.4.1
> Reporter: akram
> Assignee: Simone Bordet
> Priority: Blocker
> Fix For: 2.4.1
>
>
> While subscribing to a channel after having handshaken successfully in an asynchronous way, messages are never received on the channel.
> This is not the case when synchronous (.waitFor(10000, State.CONNECTED)) handshake is used.
> I am reusing the same LongPollingTransport for both subscription. I am using a customized transport that adds authentication header to the Exchange object.
> Here are some code Snippets:
> {code}
> httpClient = new HttpClient();
> httpClient.start();
> Map<String, Object> options = new HashMap<String, Object>();
> ClientTransport transport = new MyLongPollingTransport(options, httpClient);
> client = new BayeuxClient(Configuration.getServerURL() + COMET_PUBLISH_URI, transport);
> ClientSessionChannel channel = client.getChannel(Channel.META_HANDSHAKE);
> EventProcessor eventProcessor = new EventProcessor();
> ClientSessionChannelListener handshakeListener = new HandshakeSuccesfulListener(eventProcessor, listener);
> channel.addListener(handshakeListener);
> client.handshake();
> {code}
> Then in the HandshakeSuccesfulListener.onMessage() method:
> {code}
> if (message.isSuccessful()) {
> ClientSessionChannel push = channel.getSession().getChannel(COMET_SUBSCRIBE_URI + "/" + Configuration.getUsername());
> push.subscribe(listener);
> // push.addListener(listener); Tried this one with no difference
> eventProcessor.init();
> LOGGER.info("Handshake successful sur le channel {}", channel);
> while ( !interrupted) {
> eventProcessor.process();
> }
> }
> {code}
Reply all
Reply to author
Forward
0 new messages