Unexpected response 408 login on cometd side

I am using java cometd client. It was connected for several minutes, but after a while it registered the following error. What should I do on error 408 ? Should I disable, terminate, interrupt, or simply ignore, invoke the Java GC?

java.net.ProtocolException : Unexpected response 408 HTTP error 408 Request timeout

The web server (runs on the website) considers that between

  • establishing an IP connection (socket) between the client (for example, your web browser or our CheckUpDown robot) and the server and
  • receiving any data on this socket, so the server disconnected the connection.

The socket connection is really lost - there is a timed out on the web server on this particular socket connection. The request from the client must be repeated - in a timely manner.

extended BayeuxClient

  public class EventHostClient extends BayeuxClient { private final Logger logger = LoggerFactory.getLogger(EventHostClient.class); public EventHostClient(String url, ClientTransport transport, ClientTransport... transports) { super(url, transport, transports); } @Override public void onFailure(Throwable x, Message[] messages) { logger.info("Messages failed "+ x.getMessage()); logger.debug("Messages failed. Reason : " + Arrays.toString(messages), x); } } 

Here are the log messages

 2017-06-22 17:59:37.221 [HttpClient-2123] DEBUG cqqnieventhost.EventHostClient - Messages failed. Reason : [{id=4681, connectionType=long-polling, channel=/meta/connect, clientId=btom76smmlh9g4dyq2fkcd61}] java.net.ProtocolException: Unexpected response 408: TransportExchange@5332249c =POST//10.2.2.250:18080/cometd/connect#CONTENT(0ms)->COMPLETED(0ms)sent=1012ms at org.cometd.client.BayeuxClient$PublishTransportListener.onProtocolError(BayeuxClient.java:1161) [cometd-java-client-2.5.0.jar:na] at org.cometd.client.transport.LongPollingTransport$TransportExchange.onResponseComplete(LongPollingTransport.java:324) [cometd-java-client-2.5.0.jar:na] at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:1158) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:305) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.client.AbstractHttpConnection$Handler.messageComplete(AbstractHttpConnection.java:337) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:637) [jetty-http-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) [jetty-http-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.client.AsyncHttpConnection.handle(AsyncHttpConnection.java:133) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627) [jetty-io-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51) [jetty-io-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) [jetty-util-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) [jetty-util-7.6.7.v20120910.jar:7.6.7.v20120910] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_67] 2017-06-22 17:59:37.221 [HttpClient-2123] DEBUG cqqnisms.ChannelSubscriber - Recieved connection FAILED | {"message":{"id":"4681","connectionType":"long-polling","channel":"/meta/connect","clientId":"btom76smmlh9g4dyq2fkcd61"},"id":"4681","org.cometd.client.publishCallback":null,"exception":"java.net.ProtocolException: Unexpected response 408: TransportExchange@5332249c =POST//10.2.2.250:18080/cometd/connect#CONTENT(0ms)->COMPLETED(0ms)sent=1012ms","successful":false,"channel":"/meta/connect"} to subscriber id : 1 2017-06-22 17:59:37.221 [pool-513-thread-1] DEBUG cqqnieE1264409962 - Connecting, transport org.cometd.client.transport.LongPollingTransport@43e7229c 2017-06-22 17:59:37.221 [pool-513-thread-1] DEBUG cqqnieE1264409962 - Sending messages [{id=4683, connectionType=long-polling, channel=/meta/connect, clientId=btom76smmlh9g4dyq2fkcd61}] 2017-06-22 17:59:39.221 [pool-513-thread-1] DEBUG cqqnieE1264409962 - Connecting, transport org.cometd.client.transport.LongPollingTransport@43e7229c 2017-06-22 17:59:39.225 [pool-513-thread-1] DEBUG cqqnieE1264409962 - Sending messages [{id=4684, connectionType=long-polling, channel=/meta/connect, clientId=btom76smmlh9g4dyq2fkcd61}] 2017-06-22 17:59:39.230 [HttpClient-2123] DEBUG cqqnieE1264409962 - State update: CONNECTED -> UNCONNECTED 2017-06-22 17:59:39.230 [HttpClient-2123] INFO cqqnieventhost.EventHostClient - Messages failed Unexpected response 408: TransportExchange@101a870 =POST//10.2.2.250:18080/cometd/connect#CONTENT(0ms)->COMPLETED(0ms)sent=2009ms 2017-06-22 17:59:39.230 [HttpClient-2123] DEBUG cqqnieventhost.EventHostClient - Messages failed. Reason : [{id=4683, connectionType=long-polling, channel=/meta/connect, clientId=btom76smmlh9g4dyq2fkcd61}] java.net.ProtocolException: Unexpected response 408: TransportExchange@101a870 =POST//10.2.2.250:18080/cometd/connect#CONTENT(0ms)->COMPLETED(0ms)sent=2009ms at org.cometd.client.BayeuxClient$PublishTransportListener.onProtocolError(BayeuxClient.java:1161) [cometd-java-client-2.5.0.jar:na] at org.cometd.client.transport.LongPollingTransport$TransportExchange.onResponseComplete(LongPollingTransport.java:324) [cometd-java-client-2.5.0.jar:na] at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:1158) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:305) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.client.AbstractHttpConnection$Handler.messageComplete(AbstractHttpConnection.java:337) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:637) [jetty-http-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) [jetty-http-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.client.AsyncHttpConnection.handle(AsyncHttpConnection.java:133) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627) [jetty-io-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51) [jetty-io-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) [jetty-util-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) [jetty-util-7.6.7.v20120910.jar:7.6.7.v20120910] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_67] 2017-06-22 17:59:39.230 [HttpClient-2123] DEBUG cqqnisms.ChannelSubscriber - Recieved connection FAILED | {"message":{"id":"4683","connectionType":"long-polling","channel":"/meta/connect","clientId":"btom76smmlh9g4dyq2fkcd61"},"id":"4683","org.cometd.client.publishCallback":null,"exception":"java.net.ProtocolException: Unexpected response 408: TransportExchange@101a870 =POST//10.2.2.250:18080/cometd/connect#CONTENT(0ms)->COMPLETED(0ms)sent=2009ms","successful":false,"channel":"/meta/connect"} to subscriber id : 1 2017-06-22 17:59:40.231 [pool-513-thread-1] DEBUG cqqnieE1264409962 - Connecting, transport org.cometd.client.transport.LongPollingTransport@43e7229c 2017-06-22 17:59:40.231 [pool-513-thread-1] DEBUG cqqnieE1264409962 - Sending messages [{id=4685, connectionType=long-polling, advice={timeout=0}, channel=/meta/connect, clientId=btom76smmlh9g4dyq2fkcd61}] 2017-06-22 17:59:40.236 [HttpClient-2120] DEBUG cqqnieE1264409962 - State update: UNCONNECTED -> UNCONNECTED 2017-06-22 17:59:40.236 [HttpClient-2124] DEBUG cqqnieE1264409962 - Processing meta connect {id=4685, successful=true, channel=/meta/connect, advice={interval=0, reconnect=retry, timeout=30000}} 2017-06-22 17:59:40.236 [HttpClient-2120] INFO cqqnieventhost.EventHostClient - Messages failed Unexpected response 408: TransportExchange@13d95194 =POST//10.2.2.250:18080/cometd/connect#CONTENT(0ms)->COMPLETED(0ms)sent=1010ms 2017-06-22 17:59:40.236 [HttpClient-2124] DEBUG cqqnieE1264409962 - State update: UNCONNECTED -> CONNECTED 2017-06-22 17:59:40.236 [HttpClient-2124] DEBUG cqqnisms.ChannelSubscriber - Recieved connection confirmed | {"id":"4685","successful":true,"channel":"/meta/connect","advice":{"interval":0,"reconnect":"retry","timeout":30000}} to subscriber id : 1 2017-06-22 17:59:40.236 [HttpClient-2120] DEBUG cqqnieventhost.EventHostClient - Messages failed. Reason : [{id=4684, connectionType=long-polling, channel=/meta/connect, clientId=btom76smmlh9g4dyq2fkcd61}] java.net.ProtocolException: Unexpected response 408: TransportExchange@13d95194 =POST//10.2.2.250:18080/cometd/connect#CONTENT(0ms)->COMPLETED(0ms)sent=1010ms at org.cometd.client.BayeuxClient$PublishTransportListener.onProtocolError(BayeuxClient.java:1161) [cometd-java-client-2.5.0.jar:na] at org.cometd.client.transport.LongPollingTransport$TransportExchange.onResponseComplete(LongPollingTransport.java:324) [cometd-java-client-2.5.0.jar:na] at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:1158) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:305) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.client.AbstractHttpConnection$Handler.messageComplete(AbstractHttpConnection.java:337) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:637) [jetty-http-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) [jetty-http-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.client.AsyncHttpConnection.handle(AsyncHttpConnection.java:133) [jetty-client-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627) [jetty-io-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51) [jetty-io-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) [jetty-util-7.6.7.v20120910.jar:7.6.7.v20120910] at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) [jetty-util-7.6.7.v20120910.jar:7.6.7.v20120910] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_67] 
+5
source share
2 answers

As you saw, this is a 408 HTTP response.

Should I disable, terminate, interrupt, or simply ignore, invoke the Java GC?

  • disconnect . After the connection timeout ( 2009ms ), you really do not need to disconnect, because the client was unable to connect to the server and will repeat it according to your log.
  • complete, ignore . It really depends on your business logic. If you need to cancel transactions, etc.
  • GC challenge : it does nothing.

TL.DR .: The decision must be made based on business logic, as each network can fail in different ways.

+4
source

I raised a question on github where the project is located. The author (Mr. Simone Bordet) of the comet said that I am using a very old cometary version. He asked me to switch to Comet 3.1.2. We are currently updating our application using cometd.

https://github.com/cometd/cometd/issues/730

+1
source

Source: https://habr.com/ru/post/1269111/


All Articles