Hello,

I have performed a downgrade to 8.0.14 on Raspbian and now it is working like 
it should.
So something change between these versions in the area of the Websockets.

Kind Regards,
Christoph

> Am 19.10.2017 um 16:48 schrieb Christoph Mertins <c.mert...@gmail.com>:
> 
> Hello,
> 
> after waiting 35 minutes suddenly some events get forwarded for a second or 
> two and then again silence. 
> This is really strange.
> 
> Kind Regards,
> Christoph
> 
> Mit freundlichen Grüßen
> Christoph Mertins
> 
> On Thu, Oct 19, 2017 at 10:21 AM, Christoph Mertins <c.mert...@gmail.com 
> <mailto:c.mert...@gmail.com>> wrote:
> Hello,
> 
> I have a problem with Tomcat only sending the first message to the client and 
> then no message anymore till the client reconnects.
> 
> The code was working for some versions but then stopped working:
> 
>         public void handleEvent(EventObject eventObject) {
>                 Enumeration<String> keySet = userSessions.keys();
> 
>                 while (keySet.hasMoreElements()) {
>                         String key = keySet.nextElement();
> 
>                         Session session = userSessions.get(key);
> 
>                         synchronized (session) {
> 
>                                 if (session.isOpen()) {
>                                         try {
>                                                 Semaphore semaphore = new 
> Semaphore(1);
>                                                 Async async = 
> session.getAsyncRemote();
>                                                 SendHandler handler = new 
> SemaphoreSendHandler(semaphore, async);
> 
>                                                 String text = 
> eventTranscoder.encode(eventObject);
> 
>                                                 
> LogManager.getLogger(this.getClass())
>                                                                 
> .info("Eventbus Sending to " + session.getId() + " key: " + key + " text: " + 
> text);
> 
>                                                 if 
> (async.getBatchingAllowed()) {
>                                                         
> async.setBatchingAllowed(false);
>                                                 }
> 
>                                                 
> semaphore.acquireUninterruptibly();
> 
>                                                 async.sendText(text, handler);
>                                                 async.flushBatch();
> 
>                                                 // 
> session.getBasicRemote().sendObject(eventObject);
>                                         } catch (IllegalStateException | 
> EncodeException | IOException e) {
>                                                 
> LogManager.getLogger(this.getClass()).info("Sending failed", e);
>                                                 // userSessions.remove(key);
>                                         }
>                                 } else {
>                                         
> LogManager.getLogger(this.getClass()).info("Session not open" + key);
>                                         // userSessions.remove(key);
>                                 }
>                         }
>                 }
>         }
> 
>         private class SemaphoreSendHandler implements SendHandler {
> 
>                 private final Semaphore semaphore;
>                 private RemoteEndpoint remoteEndpoint;
> 
>                 private SemaphoreSendHandler(Semaphore semaphore, 
> RemoteEndpoint remoteEndpoint) {
>                         this.semaphore = semaphore;
>                         this.remoteEndpoint = remoteEndpoint;
>                 }
> 
>                 @Override
>                 public void onResult(SendResult result) {
>                         
> LogManager.getLogger(EventBusEndpoint.class).info("Eventbus Sent ok: " + 
> result.isOK());
>                         try {
>                                 remoteEndpoint.flushBatch();
>                                 remoteEndpoint.sendPing(ByteBuffer.wrap(new 
> byte[0]));
>                         } catch (IOException e) {
>                                 
> LogManager.getLogger(this.getClass()).info("Flushing failed", e);
>                         }
> 
>                         semaphore.release();
>                 }
>         }
> 
> I can see the SemaphoreSendHandler putting out a true for the result.isOK() 
> call.
> 
> But I can’t see any network traffic and no message on the client side. I am 
> checking the with a Chrome Extension (Simple Web Socket Client) on Chrome 61 
> and 62.
> 
> Versions:
> 
> Tomcat 8.5.21
> Java: Oracle JDK 1.8 151 (tested 131 too)
> OS: Raspbian Stretch
> 
> I cannot see any reason why this is not working.
> 
> Kind Regards,
> Christoph
> 

Reply via email to