From f040eb3824c45f47afc6d13323e7daaa496bf514 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 29 Nov 2013 18:18:04 +0200 Subject: Disable client timeout so websockets are not disconnected when idle (#13015) Updated sleep method to ensure that long sleeps can be performed without losing the connection to the browser Change-Id: I4f29d946e7a9a400e303e3a574876e1bc2d56773 --- .../client/communication/AtmospherePushConnection.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'client') diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java index 320ba9ebe7..95584412cd 100644 --- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java +++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java @@ -348,6 +348,14 @@ public class AtmospherePushConnection implements PushConnection { state = State.CONNECT_PENDING; } + protected void onClientTimeout(AtmosphereResponse response) { + state = State.DISCONNECTED; + errorHandler + .onError( + "Client unexpectedly disconnected. Ensure client timeout is disabled.", + -1); + } + protected void onReconnect(JavaScriptObject request, final AtmosphereResponse response) { if (state == State.CONNECTED) { @@ -442,6 +450,7 @@ public class AtmospherePushConnection implements PushConnection { fallbackTransport: 'streaming', contentType: 'application/json; charset=UTF-8', reconnectInterval: 5000, + timeout: -1, maxReconnectOnClose: 10000000, trackMessageLength: true, enableProtocol: false, @@ -476,6 +485,9 @@ public class AtmospherePushConnection implements PushConnection { config.onReconnect = $entry(function(request, response) { self.@com.vaadin.client.communication.AtmospherePushConnection::onReconnect(*)(request, response); }); + config.onClientTimeout = $entry(function(request) { + self.@com.vaadin.client.communication.AtmospherePushConnection::onClientTimeout(*)(request); + }); return $wnd.jQueryVaadin.atmosphere.subscribe(config); }-*/; -- cgit v1.2.3