f18a1068 by Ean Schuessler

#5084 Set comet timeout.

1 parent b8a609a2
......@@ -79,6 +79,7 @@ public class CometMessengerServlet extends HttpServlet implements CometProcessor
response.setHeader("X-Accel-Buffering", "No");
if (event.getEventType() == CometEvent.EventType.BEGIN) {
Debug.logInfo("Begin for session: " + request.getSession(true).getId(), module);
event.getHttpServletRequest().setAttribute("org.apache.tomcat.comet.timeout", new Integer(0xFFFFFFFF));
PrintWriter writer = response.getWriter();
writer.println("{\"channel\":\"system\", \"message\":\"CONNECT\"}");
writer.flush();
......
......@@ -10,9 +10,6 @@ define([], function() {
request.onreadystatechange = function() {
if (request.readyState == 3 || request.readyState == 4) {
if (request.status == 200){
if (request.onreadystatechange) {
request.onreadystatechange = null;
}
if (request.responseText) {
var newText = request.responseText.substr(responseLength);
if (newText.length > 0) {
......@@ -24,8 +21,10 @@ define([], function() {
}
}
if (request.readyState == 4) {
// Request is complete. Remove existing callback.
request.onreadystatechange = null;
if (request.status == 200) {
messenger.process();
setTimeout(function() { messenger.process(); }, 500);
} else {
console.log('Error, retrying in 5 seconds');
setTimeout(function() { messenger.process(); }, 5000);
......