0 Replies Latest reply on Sep 26, 2015 3:46 PM by Edward I

    Making ajax automatically reconnect

    Edward I Newbie

      Hi,

      Does anyone know if it's possible to automatically reconnect a browser page with a4j:push to the server after being asleep for some time?

      I use a4j:push, which works fine, but when the computer goes to sleep, it disconnects from the server.  When I start the computer again, it doesn't reconnect automatically - I need to reload the page for a4j:push to start working again.  The client (browser) also never gets notified of the disconnection with the onerror event, so there seems to be no way to inform the user that push is no longer working.

       

      The server logs the following:

      25-Sep-2015 15:46:38.559 WARNING [http-nio-7080-exec-7] org.atmosphere.websocket.WebSocket.writeError Unable to write 400 
      25-Sep-2015 15:46:38.559 WARNING [http-nio-7080-exec-7] org.atmosphere.websocket.protocol.SimpleHttpProtocol.onError Status code higher or equal than 400. Unable to deliver the websocket messages to installed component. Status 400 Message OK
      25-Sep-2015 19:33:40.834 SEVERE [http-nio-7080-exec-5] org.atmosphere.container.JSR356Endpoint.onError 
       java.io.IOException: Connection timed out
          at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
          at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
          at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
          at sun.nio.ch.IOUtil.read(IOUtil.java:197)
          at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:384)
          at org.apache.tomcat.util.net.NioChannel.read(NioChannel.java:140)
          at org.apache.coyote.http11.upgrade.NioServletInputStream.fillReadBuffer(NioServletInputStream.java:136)
          at org.apache.coyote.http11.upgrade.NioServletInputStream.doRead(NioServletInputStream.java:80)
          at org.apache.coyote.http11.upgrade.AbstractServletInputStream.read(AbstractServletInputStream.java:124)
          at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:51)
          at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler$WsReadListener.onDataAvailable(WsHttpUpgradeHandler.java:203)
          at org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream.java:198)
          at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:96)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1526)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1482)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
          at java.lang.Thread.run(Thread.java:745)
      
      25-Sep-2015 21:48:28.442 WARNING [http-nio-7080-exec-6] org.atmosphere.websocket.WebSocket.writeError Unable to write 400 
      25-Sep-2015 21:48:28.443 WARNING [http-nio-7080-exec-6] org.atmosphere.websocket.protocol.SimpleHttpProtocol.onError Status code higher or equal than 400. Unable to deliver the websocket messages to installed component. Status 400 Message OK
      

       

      Thanks for any help.