#5084 Set comet timeout.
Showing
2 changed files
with
4 additions
and
4 deletions
... | @@ -79,6 +79,7 @@ public class CometMessengerServlet extends HttpServlet implements CometProcessor | ... | @@ -79,6 +79,7 @@ public class CometMessengerServlet extends HttpServlet implements CometProcessor |
79 | response.setHeader("X-Accel-Buffering", "No"); | 79 | response.setHeader("X-Accel-Buffering", "No"); |
80 | if (event.getEventType() == CometEvent.EventType.BEGIN) { | 80 | if (event.getEventType() == CometEvent.EventType.BEGIN) { |
81 | Debug.logInfo("Begin for session: " + request.getSession(true).getId(), module); | 81 | Debug.logInfo("Begin for session: " + request.getSession(true).getId(), module); |
82 | event.getHttpServletRequest().setAttribute("org.apache.tomcat.comet.timeout", new Integer(0xFFFFFFFF)); | ||
82 | PrintWriter writer = response.getWriter(); | 83 | PrintWriter writer = response.getWriter(); |
83 | writer.println("{\"channel\":\"system\", \"message\":\"CONNECT\"}"); | 84 | writer.println("{\"channel\":\"system\", \"message\":\"CONNECT\"}"); |
84 | writer.flush(); | 85 | writer.flush(); | ... | ... |
... | @@ -10,9 +10,6 @@ define([], function() { | ... | @@ -10,9 +10,6 @@ define([], function() { |
10 | request.onreadystatechange = function() { | 10 | request.onreadystatechange = function() { |
11 | if (request.readyState == 3 || request.readyState == 4) { | 11 | if (request.readyState == 3 || request.readyState == 4) { |
12 | if (request.status == 200){ | 12 | if (request.status == 200){ |
13 | if (request.onreadystatechange) { | ||
14 | request.onreadystatechange = null; | ||
15 | } | ||
16 | if (request.responseText) { | 13 | if (request.responseText) { |
17 | var newText = request.responseText.substr(responseLength); | 14 | var newText = request.responseText.substr(responseLength); |
18 | if (newText.length > 0) { | 15 | if (newText.length > 0) { |
... | @@ -24,8 +21,10 @@ define([], function() { | ... | @@ -24,8 +21,10 @@ define([], function() { |
24 | } | 21 | } |
25 | } | 22 | } |
26 | if (request.readyState == 4) { | 23 | if (request.readyState == 4) { |
24 | // Request is complete. Remove existing callback. | ||
25 | request.onreadystatechange = null; | ||
27 | if (request.status == 200) { | 26 | if (request.status == 200) { |
28 | messenger.process(); | 27 | setTimeout(function() { messenger.process(); }, 500); |
29 | } else { | 28 | } else { |
30 | console.log('Error, retrying in 5 seconds'); | 29 | console.log('Error, retrying in 5 seconds'); |
31 | setTimeout(function() { messenger.process(); }, 5000); | 30 | setTimeout(function() { messenger.process(); }, 5000); | ... | ... |
-
Please register or sign in to post a comment