You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The relevant part starts from ---- handling 660f17c20f2fb30a8fc6fdbd. I've left some of the logging before that as I wasn't sure if it's needed. This handling print is immediately before the publish line I've given above. You can see 10 or so lines below there is a true which is from the System.err::println in the code above. Following this ID 660f17c20f2fb30a8fc6fdbd you can see at 00:12:40.884 there is a Stored at batch 19 concerning it - that's the message that I'm publishing. But then there is nothing until 00:12:52.043 when that message is actually sent. That's around 10 seconds later. The reason that's 10 seconds is that my integration test's timeout is that much - what happens is that my test depends on that message to be received and is waiting on something to change in the frontend because of it. The message doesn't arrive, the test timeouts after 10 seconds which causes the page to be torn down. That disconnects the websocket (that's the lots of unsubscribe messages you see) which for some reason causes the backend to just then send the message.
I'm not sure why that happens but I believe this is not a bug in my code?
One thing to note is that I'm using Tomcat 9.0.87 with virtual threads - I'm not sure if that's relevant or matters at all. And of course this doesn't happen every time but I can reproduce it pretty consistently.
I looked at the logs, and there is a publish to /first that wakes up a suspended /meta/connect -- this is for ack=18.
While sending the message and the /meta/connect reply, there is a publish to /second, which is stored at batch 19.
Then, the client sends another /meta/connect with ack=18, the server receives it, sees the correct acks, the logs shows that the CometD session has 1 message in the queue, but the server decides to suspend the /meta/connect, so the message for /second is not sent back to the client.
The logic to decide to suspend is to check whether the queue has non-lazy messages, so my best guess is that either that particular message is lazy or channel /second is a lazy channel, and the message is not sent.
Is that correct?
There are 2 lines in the logs exactly at that moment that are:
true
deleted
You explained the true, but not deleted -- is it relevant?
Indeed - /second is a lazy (also persistent and with publishing disabled for the client - which perhaps doesn't matter) channel.
You explained the true, but not deleted -- is it relevant?
No, sorry, I should have removed it. It's part of my code which triggers the other events - you can ignore it.
Is that enough information for you? Can you figure out where the problem is (or even if there is one)? Am I doing something wrong or is this an issue with the suspension logic you mention?
I have not configured a lazy timeout (actually I have not configured anything at all - everything is with its default value). From the documentation you linked to it seems that the default one is 5 seconds. But in my case you see that the message is not sent for more than 10 seconds.
I have not disabled maxLazyTimeout. I didn't even know there was such a setting. I had even forgotten that I'm using lazy channels and that there was such a thing. 😄
There is some race-condition somewhere. As I mentioned in the first post, this doesn't happen every time. The question is where... I'm not sure how to help more. 😞 Here's my configuration for the channel:
privatestaticfinalAuthorizerNO_PUBLISH_AUTHORIZER = (operation, channel, session, message) ->
operation == Authorizer.Operation.PUBLISH && !session.isLocalSession() ?
Authorizer.Result.deny("Publishing is not allowed on this channel!") :
Authorizer.Result.grant();
...
@Configure({ "/first", "/second", "/third" })
publicvoidconfigurePersistentLazyNoPublishChannels(ConfigurableServerChannelchannel) {
channel.setPersistent(true);
channel.setLazy(true);
channel.addAuthorizer(NO_PUBLISH_AUTHORIZER);
}
@WebListenerpublicclassBayeuxInitializerimplementsServletContextAttributeListener {
@OverridepublicvoidattributeAdded(ServletContextAttributeEventevent) {
if (BayeuxServer.ATTRIBUTE.equals(event.getName())) {
BayeuxServerbayeux = (BayeuxServer) event.getValue();
bayeux.setSecurityPolicy(newStreamingSecurityPolicy());
// https://docs.cometd.org/current/reference/#_java_server_configuration// "ws.messagesPerFrame" should not be changed from its default value of 1: https://groups.google.com/d/msg/cometd-users/xrGyhhk-8YI/aZD_MZIQBAAJ// "ws.maxMessageSize" by default has a good value: https://github.com/cometd/cometd/issues/820#issuecomment-456056108// "ws.enableExtension.permessage-deflate" is true by default so compression is enabled for WebSocketsbayeux.addListener(newStreamingService.SessionListenerImpl());
bayeux.addListener(newStreamingService.SubscriptionListenerImpl());
// https://docs.cometd.org/current/reference/#_extensions_acknowledgebayeux.addExtension(newAcknowledgedMessagesExtension());
}
}
}
That's pretty much all the configuration I have. If you have any other ideas, let me know.
Activity
sbordet commentedon Apr 21, 2024
Sorry for the late reply.
I looked at the logs, and there is a publish to
/firstthat wakes up a suspended/meta/connect-- this is forack=18.While sending the message and the
/meta/connectreply, there is a publish to/second, which is stored at batch19.Then, the client sends another
/meta/connectwithack=18, the server receives it, sees the correctacks, the logs shows that the CometD session has 1 message in the queue, but the server decides to suspend the/meta/connect, so the message for/secondis not sent back to the client.The logic to decide to suspend is to check whether the queue has non-lazy messages, so my best guess is that either that particular message is lazy or channel
/secondis a lazy channel, and the message is not sent.Is that correct?
There are 2 lines in the logs exactly at that moment that are:
You explained the
true, but notdeleted-- is it relevant?boris-petrov commentedon Apr 22, 2024
Hi, no worries.
Indeed -
/secondis a lazy (also persistent and with publishing disabled for the client - which perhaps doesn't matter) channel.No, sorry, I should have removed it. It's part of my code which triggers the other events - you can ignore it.
Is that enough information for you? Can you figure out where the problem is (or even if there is one)? Am I doing something wrong or is this an issue with the suspension logic you mention?
sbordet commentedon Apr 22, 2024
@boris-petrov there is no problem.
Since the channel is lazy, the message is not sent until some other event that would force the message to be sent, see https://docs.cometd.org/current7/reference/#_java_server_lazy_messages.
Seems to me that everything works as expected.
What's your configuration for the lazy timeout?
boris-petrov commentedon Apr 22, 2024
I have not configured a lazy timeout (actually I have not configured anything at all - everything is with its default value). From the documentation you linked to it seems that the default one is 5 seconds. But in my case you see that the message is not sent for more than 10 seconds.
sbordet commentedon Apr 23, 2024
The message should be sent after the lazy timeout expires.
I have written a test case that replicates your logs almost identically, and when the lazy timeout expires, the message is sent to the client.
Can you please double-check that you have not disabled the
maxLazyTimeout?boris-petrov commentedon Apr 23, 2024
I have not disabled
maxLazyTimeout. I didn't even know there was such a setting. I had even forgotten that I'm using lazy channels and that there was such a thing. 😄There is some race-condition somewhere. As I mentioned in the first post, this doesn't happen every time. The question is where... I'm not sure how to help more. 😞 Here's my configuration for the channel:
My
CometDservlet:And I have:
That's pretty much all the configuration I have. If you have any other ideas, let me know.