Tomcat doesn't do blazeds streaming after vers

2019-02-07 12:51发布

问题:

I found my flex application doesn't work anymore after tomcat version $subject. Please help me to get through this. I tried many things without any success.

Here is my configurations.

Blaze - 4.x Tomcat - Latest - 7.0.32 Java 7

Application just hangs without any error or anything. It works again from 7.0.32. I checked tomcat release notes (http://tomcat.apache.org/tomcat-7.0-doc/changelog.html) and isolated problem up to Coyote jar file.

When I replace Coyote.jar from version 7.0.27 to 7.0.32 it works properly.

following are changes for Coyote (http://tomcat.apache.org/tomcat-7.0-doc/changelog.html)

52858: Correct fix for high CPU load (fhanik)
53138: Broken Sendfile on SSL introduced in 7.0.27 (fhanik)
52055: Additional fix required to ensure that InputFilters are recycled between requests. (markt)
53061: Fix a problem in the NIO connector whereby if the poller was under low but consistent load (>1 request/per second and always less than 1 second between requests) timeouts never took place. (markt)
53063: When using an Executor with BIO, use the executor's maxThreads as the default for maxConnections. (markt)
53119: Prevent buffer overflow errors being reported when a client disconnects before the response has been fully written from an AJP connection using the APR/native connector. (markt)
53169: Allow developers to avoid chunked encoding for a response of unknown length by setting the Connection: close header. Based on a patch suggested by Philippe Marschall. (markt)
53173: Properly count down maxConnections (fhanik)
 Update default value of pollerThreadCount for the NIO connector. The new default value will never go above 2 regardless of available processors. (fhanik)
 Allow to retrieve the current connectionCount via getter from the endpoint and as JMX attribute of the ThreadPool mbean. (rjung)
 Correct an edge case where Comet END events were not send to connected clients when the Tomcat connector was stopped. (markt)
53406: Fix possible stack overflow on connection close when using Comet. (fhanik)
 Improve InternalNioInputBuffer.parseHeaders(). (kkolinko)
 Implement maxHeaderCount attribute on Connector. It is equivalent of LimitRequestFields directive of Apache HTTPD. Default value is 100. (kkolinko)

Any guess / idea would help. Thanks in advance!

回答1:

I think this may be the cause of the problem:

53169: Allow developers to avoid chunked encoding for a response of unknown length by setting the Connection: close header. Based on a patch suggested by Philippe Marschall. (markt)

And from BlazeDS (4.0.0.14931) code in BaseStreamingHTTPEndPoint.java:

718: res.setHeader("Connection", "close");

So, I wrote a simple filter:

@Override
public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
    chain.doFilter(request, new HttpServletResponseWrapper(
            (HttpServletResponse) response) {
        public void setHeader(String name, String value) {
            if (!("Connection".equalsIgnoreCase(name) && "Close"
                    .equalsIgnoreCase(value))) {
                super.setHeader(name, value);
            }
        }
    });
}

With configurations in web.xml:

<filter>
    <filter-name>MessageBrokerHack</filter-name>
    <filter-class>
        com.vivimice.testing.MessageBrokerHack
    </filter-class>
</filter>
<filter-mapping>
    <filter-name>MessageBrokerHack</filter-name>
    <url-pattern>/messagebroker/*</url-pattern>
</filter-mapping>

And then the problem solved.

Tested on AIR client (Flex 4.5.1) and Tomcat 6.0.36 & 7.0.35

Note: Not tested on regular RemoteObject calls yet.