Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005476 [Resin] minor always 07-01-13 15:24 07-03-13 09:05
Reporter alex View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 4.0.36
Summary 0005476: Async requests via Resin LoadBalancer
Description Comet requests return prematurely if requested via load balancer.

<html>
  <head>
    <title>test</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
    <script type="text/javascript">
      var i = 0; function test() {
        if (i++ > 32) return; $.ajax({
          type: 'GET',
          url: 'async'
        });
        get(Math.floor(Math.random() * 100));
      }
      function get(n) {
        $.ajax({
          type: 'GET',
          url: 'image.png',
          data: { '_': n },
          success: function() { setTimeout(test, 1000); }
        });
      }
      $(function() {
           test();
      });
    </script>
  </head>
  <body></body>
</html>


package jp.co.intra_mart;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import javax.servlet.AsyncContext;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class AsyncServlet extends GenericServlet {
    @Override
    public void service(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
        final AsyncContext context = request.startAsync();

        context.setTimeout(30 * 1000);
        context.start(new Runnable() {
            @Override
            public void run() {
                try {
                    TimeUnit.SECONDS.sleep(5);
                } catch (final Exception e) {
                    e.printStackTrace();
                } finally {
                    context.complete();
                }
            }
        });
    }
}



package jp.co.intra_mart;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ResinIISTestServlet extends HttpServlet {
    @Override
    protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
        final StringBuilder builder = new StringBuilder(1024);

        builder.append("<html>\n");
        builder.append(" <head>\n");
        builder.append(" <title>test</title>\n");
        builder.append(" <script src=\"//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js\"></script>\n");
        builder.append(" <script type=\"text/javascript\">\n");
        builder.append(" var i = 0;");
        builder.append(" function test() {\n");
        builder.append(" if (i++ > 32) return;");
        builder.append(" $.ajax({\n");
        builder.append(" type: 'GET',\n");
        builder.append(" url: 'async'\n");
        builder.append(" });\n");
        builder.append(" get(Math.floor(Math.random() * 100));\n");
        builder.append(" }\n");
        builder.append(" function get(n) {\n");
        builder.append(" $.ajax({\n");
        builder.append(" type: 'GET',\n");
        builder.append(" url: 'image.png',\n");
        builder.append(" data: { '_': n },\n");
        builder.append(" success: function() { setTimeout(test, 1000); }\n");
        builder.append(" });\n");
        builder.append(" }\n");
        builder.append(" $(function() {\n");
        builder.append(" test();\n");
        builder.append(" });\n");
        builder.append(" </script>\n");
        builder.append(" </head>\n");
        builder.append(" <body></body>\n");
        builder.append("</html>\n");

        resp.getWriter().write(builder.toString());
    }
}

Additional Information <?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" [^] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" [^] metadata-complete="false" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee [^] http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> [^]
    <servlet>
        <servlet-name>ResinIISTestServlet</servlet-name>
        <servlet-class>jp.co.intra_mart.ResinIISTestServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>AsyncServlet</servlet-name>
        <servlet-class>jp.co.intra_mart.AsyncServlet</servlet-class>
        <async-supported>true</async-supported>
    </servlet>

    <servlet-mapping>
        <servlet-name>ResinIISTestServlet</servlet-name>
        <url-pattern>/test</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>AsyncServlet</servlet-name>
        <url-pattern>/async</url-pattern>
    </servlet-mapping>
</web-app>
Attached Files

- Relationships

- Notes
(0006292)
ferg
07-03-13 09:05

server/26u2
 

- Issue History
Date Modified Username Field Change
07-01-13 15:24 alex New Issue
07-01-13 15:43 alex Description Updated
07-01-13 16:57 yanonaoki Issue Monitored: yanonaoki
07-03-13 09:05 ferg Note Added: 0006292
07-03-13 09:05 ferg Assigned To  => ferg
07-03-13 09:05 ferg Status new => closed
07-03-13 09:05 ferg Resolution open => fixed
07-03-13 09:05 ferg Fixed in Version  => 4.0.37


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
32 total queries executed.
27 unique queries executed.
Powered by Mantis Bugtracker