Re: Async servlet and request recycling

2016-11-02 Thread Mark Thomas
On 02/11/2016 08:51, Thomas Boniface wrote:
> I'm glad this was useful in the end.
> 
> Could you send the link to the corresponding issue ? I'd be interesting to
> read the commit for the fix and known the tomcat versions this will be
> pushed to.

There is no issue.

In terms of the commits, look at commits from me yesterday.

It was fixed in for branches that support async so 7.0.x to 9.0.x. For
exact versions, see the changelog entries that are part of those commits.

Mark

> 
> Thanks
> 
> 2016-11-01 11:08 GMT+01:00 Mark Thomas :
> 
>> On 25/10/2016 09:59, Mark Thomas wrote:
>>> Thanks for this.
>>>
>>> While I haven't had a chance to look into this, there is enough
>>> information here to justify opening a bug report. That has the added
>>> advantage that it won't get forogtten.
>>
>> I've found the time to look at this.
>>
>> There was a bug. While Tomcat did clean up its internal resources
>> correctly, it didn't call onError() so the app was never given a chance
>> to clean up unless it did so as a result of the original IOException.
>>
>> The app should call onComplete() from onError() (as required by the
>> spec). It it doesn't, that will trigger another error and Tomcat will
>> call on onComplete()
>>
>> This should be fixed in the next set of releases.
>>
>> Mark
>>
>>
>>>
>>> Mark
>>>
>>>
>>> On 18/10/2016 09:55, Thomas Boniface wrote:
 Just a small correction, the callback was a bit weird. The correct one
>> is
 below (but that doesn't impact the behavior of the scenario)

 @Override
 public void completed(HttpResponse result) {
 try {
 try {
 Thread.sleep(200);
 } catch (InterruptedException e) {
 e.printStackTrace();
 }

 ServletOutputStream out = res.getOutputStream();
 out.print("Hello world");
 out.flush();
 out.close();
 } catch (IOException e) {
 } finally {
 req.getAsyncContext().complete();
 }
 }


 2016-10-18 10:38 GMT+02:00 Thomas Boniface :
>
> I think I managed to narrow things down a bit.
>
>
> I managed to reproduced locally the issue (it's not occuring 100% of
>> the
 time but it appears after a very few attempt for me). I created a really
 basic webapps :
>
> package stickyads.tv;
>
> import org.apache.http.HttpResponse;
> import org.apache.http.client.methods.HttpGet;
> import org.apache.http.concurrent.FutureCallback;
> import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
> import org.apache.http.impl.nio.client.HttpAsyncClients;
>
> import javax.servlet.*;
> import javax.servlet.annotation.WebServlet;
> import java.io.IOException;
>
> @WebServlet(value="/hello", name="helloServlet", asyncSupported = true)
> public class HelloServlet extends GenericServlet {
>
> private static final CloseableHttpAsyncClient httpclient =
 HttpAsyncClients.createDefault();
> static {
> httpclient.start();
> }
>
> @Override
> public void service(final ServletRequest req, final ServletResponse
 res) throws ServletException, IOException {
> req.startAsync();
>
> HttpGet request = new HttpGet("http://www.apache.org/;);
> httpclient.execute(request, new FutureCallback()
>> {
> @Override
> public void completed(HttpResponse result) {
> try {
> try {
> Thread.sleep(200);
> } catch (InterruptedException e) {
> e.printStackTrace();
> }
>
> ServletOutputStream out = res.getOutputStream();
> out.print("Hello world");
> out.flush();
> out.close();
> } catch (IOException e) {
> // this will generate an NPE
> req.getAsyncContext().complete();
> }
> }
>
> @Override
> public void failed(Exception ex) {
>
> }
>
> @Override
> public void cancelled() {
>
> }
> });
> }
> }
>
> I deploy the war on tomcat 7.0.72 and then call it using a simple
>> python
 program that sends a request and closes the requests without waiting
>> for a
 response:
>
> import socket
>
> # create an INET, STREAMing socket
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> # now connect to the web server on port 80 - the normal http port
> s.connect(("127.0.0.1", 8080))
> s.send("GET /broken-pipe-1.0-SNAPSHOT/hello
 

Re: Async servlet and request recycling

2016-11-02 Thread Thomas Boniface
I'm glad this was useful in the end.

Could you send the link to the corresponding issue ? I'd be interesting to
read the commit for the fix and known the tomcat versions this will be
pushed to.

Thanks

2016-11-01 11:08 GMT+01:00 Mark Thomas :

> On 25/10/2016 09:59, Mark Thomas wrote:
> > Thanks for this.
> >
> > While I haven't had a chance to look into this, there is enough
> > information here to justify opening a bug report. That has the added
> > advantage that it won't get forogtten.
>
> I've found the time to look at this.
>
> There was a bug. While Tomcat did clean up its internal resources
> correctly, it didn't call onError() so the app was never given a chance
> to clean up unless it did so as a result of the original IOException.
>
> The app should call onComplete() from onError() (as required by the
> spec). It it doesn't, that will trigger another error and Tomcat will
> call on onComplete()
>
> This should be fixed in the next set of releases.
>
> Mark
>
>
> >
> > Mark
> >
> >
> > On 18/10/2016 09:55, Thomas Boniface wrote:
> >> Just a small correction, the callback was a bit weird. The correct one
> is
> >> below (but that doesn't impact the behavior of the scenario)
> >>
> >> @Override
> >> public void completed(HttpResponse result) {
> >> try {
> >> try {
> >> Thread.sleep(200);
> >> } catch (InterruptedException e) {
> >> e.printStackTrace();
> >> }
> >>
> >> ServletOutputStream out = res.getOutputStream();
> >> out.print("Hello world");
> >> out.flush();
> >> out.close();
> >> } catch (IOException e) {
> >> } finally {
> >> req.getAsyncContext().complete();
> >> }
> >> }
> >>
> >>
> >> 2016-10-18 10:38 GMT+02:00 Thomas Boniface :
> >>>
> >>> I think I managed to narrow things down a bit.
> >>>
> >>>
> >>> I managed to reproduced locally the issue (it's not occuring 100% of
> the
> >> time but it appears after a very few attempt for me). I created a really
> >> basic webapps :
> >>>
> >>> package stickyads.tv;
> >>>
> >>> import org.apache.http.HttpResponse;
> >>> import org.apache.http.client.methods.HttpGet;
> >>> import org.apache.http.concurrent.FutureCallback;
> >>> import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
> >>> import org.apache.http.impl.nio.client.HttpAsyncClients;
> >>>
> >>> import javax.servlet.*;
> >>> import javax.servlet.annotation.WebServlet;
> >>> import java.io.IOException;
> >>>
> >>> @WebServlet(value="/hello", name="helloServlet", asyncSupported = true)
> >>> public class HelloServlet extends GenericServlet {
> >>>
> >>> private static final CloseableHttpAsyncClient httpclient =
> >> HttpAsyncClients.createDefault();
> >>> static {
> >>> httpclient.start();
> >>> }
> >>>
> >>> @Override
> >>> public void service(final ServletRequest req, final ServletResponse
> >> res) throws ServletException, IOException {
> >>> req.startAsync();
> >>>
> >>> HttpGet request = new HttpGet("http://www.apache.org/;);
> >>> httpclient.execute(request, new FutureCallback()
> {
> >>> @Override
> >>> public void completed(HttpResponse result) {
> >>> try {
> >>> try {
> >>> Thread.sleep(200);
> >>> } catch (InterruptedException e) {
> >>> e.printStackTrace();
> >>> }
> >>>
> >>> ServletOutputStream out = res.getOutputStream();
> >>> out.print("Hello world");
> >>> out.flush();
> >>> out.close();
> >>> } catch (IOException e) {
> >>> // this will generate an NPE
> >>> req.getAsyncContext().complete();
> >>> }
> >>> }
> >>>
> >>> @Override
> >>> public void failed(Exception ex) {
> >>>
> >>> }
> >>>
> >>> @Override
> >>> public void cancelled() {
> >>>
> >>> }
> >>> });
> >>> }
> >>> }
> >>>
> >>> I deploy the war on tomcat 7.0.72 and then call it using a simple
> python
> >> program that sends a request and closes the requests without waiting
> for a
> >> response:
> >>>
> >>> import socket
> >>>
> >>> # create an INET, STREAMing socket
> >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> >>> # now connect to the web server on port 80 - the normal http port
> >>> s.connect(("127.0.0.1", 8080))
> >>> s.send("GET /broken-pipe-1.0-SNAPSHOT/hello
> >> HTTP/1.1\nHost:127.0.0.1\nX-Forwarded-For: 127.0.0.1\nX-Forwarded-
> Protocol:
> >> http\n\n")
> >>>
> >>> This result in a broken pipe exception, a recycling of the async
> context
> >> but no complete:
> >>>
> >>> INFO: An error occurred in processing while on a non-container thread.
> >> The connection will be closed immediately
> 

Re: Async servlet and request recycling

2016-11-01 Thread Mark Thomas
On 25/10/2016 09:59, Mark Thomas wrote:
> Thanks for this.
> 
> While I haven't had a chance to look into this, there is enough
> information here to justify opening a bug report. That has the added
> advantage that it won't get forogtten.

I've found the time to look at this.

There was a bug. While Tomcat did clean up its internal resources
correctly, it didn't call onError() so the app was never given a chance
to clean up unless it did so as a result of the original IOException.

The app should call onComplete() from onError() (as required by the
spec). It it doesn't, that will trigger another error and Tomcat will
call on onComplete()

This should be fixed in the next set of releases.

Mark


> 
> Mark
> 
> 
> On 18/10/2016 09:55, Thomas Boniface wrote:
>> Just a small correction, the callback was a bit weird. The correct one is
>> below (but that doesn't impact the behavior of the scenario)
>>
>> @Override
>> public void completed(HttpResponse result) {
>> try {
>> try {
>> Thread.sleep(200);
>> } catch (InterruptedException e) {
>> e.printStackTrace();
>> }
>>
>> ServletOutputStream out = res.getOutputStream();
>> out.print("Hello world");
>> out.flush();
>> out.close();
>> } catch (IOException e) {
>> } finally {
>> req.getAsyncContext().complete();
>> }
>> }
>>
>>
>> 2016-10-18 10:38 GMT+02:00 Thomas Boniface :
>>>
>>> I think I managed to narrow things down a bit.
>>>
>>>
>>> I managed to reproduced locally the issue (it's not occuring 100% of the
>> time but it appears after a very few attempt for me). I created a really
>> basic webapps :
>>>
>>> package stickyads.tv;
>>>
>>> import org.apache.http.HttpResponse;
>>> import org.apache.http.client.methods.HttpGet;
>>> import org.apache.http.concurrent.FutureCallback;
>>> import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
>>> import org.apache.http.impl.nio.client.HttpAsyncClients;
>>>
>>> import javax.servlet.*;
>>> import javax.servlet.annotation.WebServlet;
>>> import java.io.IOException;
>>>
>>> @WebServlet(value="/hello", name="helloServlet", asyncSupported = true)
>>> public class HelloServlet extends GenericServlet {
>>>
>>> private static final CloseableHttpAsyncClient httpclient =
>> HttpAsyncClients.createDefault();
>>> static {
>>> httpclient.start();
>>> }
>>>
>>> @Override
>>> public void service(final ServletRequest req, final ServletResponse
>> res) throws ServletException, IOException {
>>> req.startAsync();
>>>
>>> HttpGet request = new HttpGet("http://www.apache.org/;);
>>> httpclient.execute(request, new FutureCallback() {
>>> @Override
>>> public void completed(HttpResponse result) {
>>> try {
>>> try {
>>> Thread.sleep(200);
>>> } catch (InterruptedException e) {
>>> e.printStackTrace();
>>> }
>>>
>>> ServletOutputStream out = res.getOutputStream();
>>> out.print("Hello world");
>>> out.flush();
>>> out.close();
>>> } catch (IOException e) {
>>> // this will generate an NPE
>>> req.getAsyncContext().complete();
>>> }
>>> }
>>>
>>> @Override
>>> public void failed(Exception ex) {
>>>
>>> }
>>>
>>> @Override
>>> public void cancelled() {
>>>
>>> }
>>> });
>>> }
>>> }
>>>
>>> I deploy the war on tomcat 7.0.72 and then call it using a simple python
>> program that sends a request and closes the requests without waiting for a
>> response:
>>>
>>> import socket
>>>
>>> # create an INET, STREAMing socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> # now connect to the web server on port 80 - the normal http port
>>> s.connect(("127.0.0.1", 8080))
>>> s.send("GET /broken-pipe-1.0-SNAPSHOT/hello
>> HTTP/1.1\nHost:127.0.0.1\nX-Forwarded-For: 127.0.0.1\nX-Forwarded-Protocol:
>> http\n\n")
>>>
>>> This result in a broken pipe exception, a recycling of the async context
>> but no complete:
>>>
>>> INFO: An error occurred in processing while on a non-container thread.
>> The connection will be closed immediately
>>> java.net.SocketException: Broken pipe
>>> at java.net.SocketOutputStream.$$YJP$$socketWrite0(Native Method)
>>> at java.net.SocketOutputStream.socketWrite0(SocketOutputStream.java)
>>> at
>> java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
>>> at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
>>> at
>> org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215)
>>> at
>> org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
>>>

Re: Async servlet and request recycling

2016-10-25 Thread Mark Thomas
Thanks for this.

While I haven't had a chance to look into this, there is enough
information here to justify opening a bug report. That has the added
advantage that it won't get forogtten.

Mark


On 18/10/2016 09:55, Thomas Boniface wrote:
> Just a small correction, the callback was a bit weird. The correct one is
> below (but that doesn't impact the behavior of the scenario)
> 
> @Override
> public void completed(HttpResponse result) {
> try {
> try {
> Thread.sleep(200);
> } catch (InterruptedException e) {
> e.printStackTrace();
> }
> 
> ServletOutputStream out = res.getOutputStream();
> out.print("Hello world");
> out.flush();
> out.close();
> } catch (IOException e) {
> } finally {
> req.getAsyncContext().complete();
> }
> }
> 
> 
> 2016-10-18 10:38 GMT+02:00 Thomas Boniface :
>>
>> I think I managed to narrow things down a bit.
>>
>>
>> I managed to reproduced locally the issue (it's not occuring 100% of the
> time but it appears after a very few attempt for me). I created a really
> basic webapps :
>>
>> package stickyads.tv;
>>
>> import org.apache.http.HttpResponse;
>> import org.apache.http.client.methods.HttpGet;
>> import org.apache.http.concurrent.FutureCallback;
>> import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
>> import org.apache.http.impl.nio.client.HttpAsyncClients;
>>
>> import javax.servlet.*;
>> import javax.servlet.annotation.WebServlet;
>> import java.io.IOException;
>>
>> @WebServlet(value="/hello", name="helloServlet", asyncSupported = true)
>> public class HelloServlet extends GenericServlet {
>>
>> private static final CloseableHttpAsyncClient httpclient =
> HttpAsyncClients.createDefault();
>> static {
>> httpclient.start();
>> }
>>
>> @Override
>> public void service(final ServletRequest req, final ServletResponse
> res) throws ServletException, IOException {
>> req.startAsync();
>>
>> HttpGet request = new HttpGet("http://www.apache.org/;);
>> httpclient.execute(request, new FutureCallback() {
>> @Override
>> public void completed(HttpResponse result) {
>> try {
>> try {
>> Thread.sleep(200);
>> } catch (InterruptedException e) {
>> e.printStackTrace();
>> }
>>
>> ServletOutputStream out = res.getOutputStream();
>> out.print("Hello world");
>> out.flush();
>> out.close();
>> } catch (IOException e) {
>> // this will generate an NPE
>> req.getAsyncContext().complete();
>> }
>> }
>>
>> @Override
>> public void failed(Exception ex) {
>>
>> }
>>
>> @Override
>> public void cancelled() {
>>
>> }
>> });
>> }
>> }
>>
>> I deploy the war on tomcat 7.0.72 and then call it using a simple python
> program that sends a request and closes the requests without waiting for a
> response:
>>
>> import socket
>>
>> # create an INET, STREAMing socket
>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>> # now connect to the web server on port 80 - the normal http port
>> s.connect(("127.0.0.1", 8080))
>> s.send("GET /broken-pipe-1.0-SNAPSHOT/hello
> HTTP/1.1\nHost:127.0.0.1\nX-Forwarded-For: 127.0.0.1\nX-Forwarded-Protocol:
> http\n\n")
>>
>> This result in a broken pipe exception, a recycling of the async context
> but no complete:
>>
>> INFO: An error occurred in processing while on a non-container thread.
> The connection will be closed immediately
>> java.net.SocketException: Broken pipe
>> at java.net.SocketOutputStream.$$YJP$$socketWrite0(Native Method)
>> at java.net.SocketOutputStream.socketWrite0(SocketOutputStream.java)
>> at
> java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
>> at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
>> at
> org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215)
>> at
> org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
>> at
> org.apache.coyote.http11.InternalOutputBuffer.endRequest(InternalOutputBuffer.java:159)
>> at
> org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:761)
>> at org.apache.coyote.Response.action(Response.java:174)
>> at org.apache.coyote.Response.finish(Response.java:274)
>> at
> org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:322)
>> at
> org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:108)
>> at stickyads.tv.HelloServlet$1.completed(HelloServlet.java:33)
>> at stickyads.tv.HelloServlet$1.completed(HelloServlet.java:26)

Re: Async servlet and request recycling

2016-10-18 Thread Thomas Boniface
Just a small correction, the callback was a bit weird. The correct one is
below (but that doesn't impact the behavior of the scenario)

@Override
public void completed(HttpResponse result) {
try {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}

ServletOutputStream out = res.getOutputStream();
out.print("Hello world");
out.flush();
out.close();
} catch (IOException e) {
} finally {
req.getAsyncContext().complete();
}
}


2016-10-18 10:38 GMT+02:00 Thomas Boniface :
>
> I think I managed to narrow things down a bit.
>
>
> I managed to reproduced locally the issue (it's not occuring 100% of the
time but it appears after a very few attempt for me). I created a really
basic webapps :
>
> package stickyads.tv;
>
> import org.apache.http.HttpResponse;
> import org.apache.http.client.methods.HttpGet;
> import org.apache.http.concurrent.FutureCallback;
> import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
> import org.apache.http.impl.nio.client.HttpAsyncClients;
>
> import javax.servlet.*;
> import javax.servlet.annotation.WebServlet;
> import java.io.IOException;
>
> @WebServlet(value="/hello", name="helloServlet", asyncSupported = true)
> public class HelloServlet extends GenericServlet {
>
> private static final CloseableHttpAsyncClient httpclient =
HttpAsyncClients.createDefault();
> static {
> httpclient.start();
> }
>
> @Override
> public void service(final ServletRequest req, final ServletResponse
res) throws ServletException, IOException {
> req.startAsync();
>
> HttpGet request = new HttpGet("http://www.apache.org/;);
> httpclient.execute(request, new FutureCallback() {
> @Override
> public void completed(HttpResponse result) {
> try {
> try {
> Thread.sleep(200);
> } catch (InterruptedException e) {
> e.printStackTrace();
> }
>
> ServletOutputStream out = res.getOutputStream();
> out.print("Hello world");
> out.flush();
> out.close();
> } catch (IOException e) {
> // this will generate an NPE
> req.getAsyncContext().complete();
> }
> }
>
> @Override
> public void failed(Exception ex) {
>
> }
>
> @Override
> public void cancelled() {
>
> }
> });
> }
> }
>
> I deploy the war on tomcat 7.0.72 and then call it using a simple python
program that sends a request and closes the requests without waiting for a
response:
>
> import socket
>
> # create an INET, STREAMing socket
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> # now connect to the web server on port 80 - the normal http port
> s.connect(("127.0.0.1", 8080))
> s.send("GET /broken-pipe-1.0-SNAPSHOT/hello
HTTP/1.1\nHost:127.0.0.1\nX-Forwarded-For: 127.0.0.1\nX-Forwarded-Protocol:
http\n\n")
>
> This result in a broken pipe exception, a recycling of the async context
but no complete:
>
> INFO: An error occurred in processing while on a non-container thread.
The connection will be closed immediately
> java.net.SocketException: Broken pipe
> at java.net.SocketOutputStream.$$YJP$$socketWrite0(Native Method)
> at java.net.SocketOutputStream.socketWrite0(SocketOutputStream.java)
> at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
> at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
> at
org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215)
> at
org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
> at
org.apache.coyote.http11.InternalOutputBuffer.endRequest(InternalOutputBuffer.java:159)
> at
org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:761)
> at org.apache.coyote.Response.action(Response.java:174)
> at org.apache.coyote.Response.finish(Response.java:274)
> at
org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:322)
> at
org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:108)
> at stickyads.tv.HelloServlet$1.completed(HelloServlet.java:33)
> at stickyads.tv.HelloServlet$1.completed(HelloServlet.java:26)
> at
org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:119)
> at
org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:177)
> at
org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:412)
> at

Re: Async servlet and request recycling

2016-10-18 Thread Thomas Boniface
I think I managed to narrow things down a bit.


I managed to reproduced locally the issue (it's not occuring 100% of the
time but it appears after a very few attempt for me). I created a really
basic webapps :

package stickyads.tv;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClients;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;

@WebServlet(value="/hello", name="helloServlet", asyncSupported = true)
public class HelloServlet extends GenericServlet {

private static final CloseableHttpAsyncClient httpclient =
HttpAsyncClients.createDefault();
static {
httpclient.start();
}

@Override
public void service(final ServletRequest req, final ServletResponse
res) throws ServletException, IOException {
req.startAsync();

HttpGet request = new HttpGet("http://www.apache.org/;);
httpclient.execute(request, new FutureCallback() {
@Override
public void completed(HttpResponse result) {
try {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}

ServletOutputStream out = res.getOutputStream();
out.print("Hello world");
out.flush();
out.close();
} catch (IOException e) {
// this will generate an NPE
req.getAsyncContext().complete();
}
}

@Override
public void failed(Exception ex) {

}

@Override
public void cancelled() {

}
});
}
}

I deploy the war on tomcat 7.0.72 and then call it using a simple python
program that sends a request and closes the requests without waiting for a
response:

import socket

# create an INET, STREAMing socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# now connect to the web server on port 80 - the normal http port
s.connect(("127.0.0.1", 8080))
s.send("GET /broken-pipe-1.0-SNAPSHOT/hello
HTTP/1.1\nHost:127.0.0.1\nX-Forwarded-For:
127.0.0.1\nX-Forwarded-Protocol: http\n\n")

This result in a broken pipe exception, a recycling of the async context
but no complete:

INFO: An error occurred in processing while on a non-container thread. The
connection will be closed immediately
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.$$YJP$$socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite0(SocketOutputStream.java)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(
InternalOutputBuffer.java:215)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
at org.apache.coyote.http11.InternalOutputBuffer.endRequest(
InternalOutputBuffer.java:159)
at org.apache.coyote.http11.AbstractHttp11Processor.action(
AbstractHttp11Processor.java:761)
at org.apache.coyote.Response.action(Response.java:174)
at org.apache.coyote.Response.finish(Response.java:274)
at org.apache.catalina.connector.OutputBuffer.close(
OutputBuffer.java:322)
at org.apache.catalina.connector.CoyoteOutputStream.close(
CoyoteOutputStream.java:108)
at stickyads.tv.HelloServlet$1.completed(HelloServlet.java:33)
at stickyads.tv.HelloServlet$1.completed(HelloServlet.java:26)
at org.apache.http.concurrent.BasicFuture.completed(
BasicFuture.java:119)
at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerIm
pl.responseCompleted(DefaultClientExchangeHandlerImpl.java:177)
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.
processResponse(HttpAsyncRequestExecutor.java:412)
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(
HttpAsyncRequestExecutor.java:305)
at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(
DefaultNHttpClientConnection.java:267)
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(
InternalIODispatch.java:81)
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(
InternalIODispatch.java:39)
at org.apache.http.impl.nio.reactor.AbstractIODispatch.
inputReady(AbstractIODispatch.java:116)
at org.apache.http.impl.nio.reactor.BaseIOReactor.
readable(BaseIOReactor.java:164)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(
AbstractIOReactor.java:339)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(
AbstractIOReactor.java:317)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.

Re: Async servlet and request recycling

2016-10-10 Thread Mark Thomas
On 10/10/2016 15:47, Thomas Boniface wrote:
> Hello,
> 
> I have managed to test this use case on the server revealing the issue with
> the latest tomcat release (7.0.72). I still can observe the issue on
> catalina.out side: a broken pipe exception pops up and a recycle is shown
> for the async context but no complete.

Steps to reproduce?

Better still, a test case that demonstrates the issue?

Mark


> 
> Oct 10, 2016 4:41:07 PM org.apache.coyote.AbstractProcessor setErrorState
> INFO: An error occurred in processing while on a non-container thread. The
> connection will be closed immediately
> java.net.SocketException: Broken pipe
> at java.net.SocketOutputStream.$$YJP$$socketWrite0(Native Method)
> at java.net.SocketOutputStream.socketWrite0(SocketOutputStream.java)
> at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
> at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
> at
> org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215)
> at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
> at
> org.apache.coyote.http11.InternalOutputBuffer.endRequest(InternalOutputBuffer.java:159)
> at
> org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:761)
> at org.apache.coyote.Response.action(Response.java:174)
> at org.apache.coyote.Response.finish(Response.java:274)
> at
> org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:322)
> at
> org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:108)
> ...
> Oct 10, 2016 4:41:07 PM org.apache.catalina.core.AsyncContextImpl logDebug
> FINE: Req: 2de85b25  CReq: 70e2c044  RP: 1dff11c5  Stage: 7  Thread:
> http-bio-8080-exec-8  State:  N/A  Method: recycle
> URI:
> /www/delivery/swfIndex.php?reqType=AdsSetup=2.0=5335
> 
> On application logs side the behavior changed a bit as I now have a
> IllegalStateException:
> 
> java.lang.IllegalStateException: It is illegal to call this method if the
> current request is not in asynchronous mode (i.e. isAsyncStarted() returns
> false)
> at
> org.apache.catalina.connector.Request.getAsyncContext(Request.java:1740)
> ~[catalina.jar:7.0.72]
> 
> In the end, the situation seems pretty similar. The container appears to
> recycle the request without completing the async context and I can't
> complete on application side as the request I have is now recycled.
> 
> Thanks,
> Thomas
> 
> 
> 2016-10-03 17:06 GMT+02:00 Thomas Boniface :
> 
>> Hi,
>>
>> Thanks for your feedbacks. I noticed the issue I described do not occur on
>> my local or integration environment. I still try to figure out how to
>> reproduce this in an environment I can easely update to the latest tomcat
>> version.
>>
>> Although it may not occur in latest release. Could you give me an input on
>> what are the consequences of the behaviour I described ?
>>
>> Thanks,
>> Thomas
>>
>> 2016-09-29 9:41 GMT+02:00 Violeta Georgieva :
>>
>>> Hi,
>>>
>>> 2016-09-29 10:14 GMT+03:00 Thomas Boniface :

 The tomcat version is 7.0.64.
>>>
>>> I would recommend you to verify the behaviour against the latest Tomcat 7
>>> (7.0.72).
>>> We have changes in the async processing since 7.0.64.
>>> http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
>>>
>>> Regards,
>>> Violeta
>>>
 Thomas

 2016-09-28 22:43 GMT+02:00 Christopher Schultz <
>>> ch...@christopherschultz.net
> :

> Thomas,
> 
> On 9/28/16 11:55 AM, Thomas Boniface wrote:
>>> Hi,
>>>
>>> When a client calls an asynchronous servlet and closes the
>>> connection a java.io.IOException: Broken pipe is catched by Tomcat
>>> level when the webapp tries to write to the socket.
>>>
>>> This exception is not transmited to the webapp level but it seems
>>> the request has been recycled (all content is reinitialised), in
>>> such a case it impossible for the webapp to retrieve the
>>> AsyncContext from the HttpServletRequest making the AsyncContext
>>> complete call impossible.
>>>
>>> Activating the tomcat logging for AsyncContext
>>> (org.apache.catalina.core.AsyncContextImpl.level = FINE) shows the
>>> recycle method is called but not the complete method, what seems to
>>> confirm my assumption. In a use case were the client waits for the
>>> response, I can see both complete and recycle are called.
>>>
>>> My question is, what is the impact of the complete not being called
>>> on the AsyncContext, is the socket cleaned up properly ?
> 
> Tomcat version?
> 
> -chris
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>
>>>
>>
>>
> 



Re: Async servlet and request recycling

2016-10-10 Thread Thomas Boniface
Hello,

I have managed to test this use case on the server revealing the issue with
the latest tomcat release (7.0.72). I still can observe the issue on
catalina.out side: a broken pipe exception pops up and a recycle is shown
for the async context but no complete.

Oct 10, 2016 4:41:07 PM org.apache.coyote.AbstractProcessor setErrorState
INFO: An error occurred in processing while on a non-container thread. The
connection will be closed immediately
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.$$YJP$$socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite0(SocketOutputStream.java)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
at
org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
at
org.apache.coyote.http11.InternalOutputBuffer.endRequest(InternalOutputBuffer.java:159)
at
org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:761)
at org.apache.coyote.Response.action(Response.java:174)
at org.apache.coyote.Response.finish(Response.java:274)
at
org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:322)
at
org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:108)
...
Oct 10, 2016 4:41:07 PM org.apache.catalina.core.AsyncContextImpl logDebug
FINE: Req: 2de85b25  CReq: 70e2c044  RP: 1dff11c5  Stage: 7  Thread:
http-bio-8080-exec-8  State:  N/A  Method: recycle
URI:
/www/delivery/swfIndex.php?reqType=AdsSetup=2.0=5335

On application logs side the behavior changed a bit as I now have a
IllegalStateException:

java.lang.IllegalStateException: It is illegal to call this method if the
current request is not in asynchronous mode (i.e. isAsyncStarted() returns
false)
at
org.apache.catalina.connector.Request.getAsyncContext(Request.java:1740)
~[catalina.jar:7.0.72]

In the end, the situation seems pretty similar. The container appears to
recycle the request without completing the async context and I can't
complete on application side as the request I have is now recycled.

Thanks,
Thomas


2016-10-03 17:06 GMT+02:00 Thomas Boniface :

> Hi,
>
> Thanks for your feedbacks. I noticed the issue I described do not occur on
> my local or integration environment. I still try to figure out how to
> reproduce this in an environment I can easely update to the latest tomcat
> version.
>
> Although it may not occur in latest release. Could you give me an input on
> what are the consequences of the behaviour I described ?
>
> Thanks,
> Thomas
>
> 2016-09-29 9:41 GMT+02:00 Violeta Georgieva :
>
>> Hi,
>>
>> 2016-09-29 10:14 GMT+03:00 Thomas Boniface :
>> >
>> > The tomcat version is 7.0.64.
>>
>> I would recommend you to verify the behaviour against the latest Tomcat 7
>> (7.0.72).
>> We have changes in the async processing since 7.0.64.
>> http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
>>
>> Regards,
>> Violeta
>>
>> > Thomas
>> >
>> > 2016-09-28 22:43 GMT+02:00 Christopher Schultz <
>> ch...@christopherschultz.net
>> > >:
>> >
>> > > -BEGIN PGP SIGNED MESSAGE-
>> > > Hash: SHA256
>> > >
>> > > Thomas,
>> > >
>> > > On 9/28/16 11:55 AM, Thomas Boniface wrote:
>> > > > Hi,
>> > > >
>> > > > When a client calls an asynchronous servlet and closes the
>> > > > connection a java.io.IOException: Broken pipe is catched by Tomcat
>> > > > level when the webapp tries to write to the socket.
>> > > >
>> > > > This exception is not transmited to the webapp level but it seems
>> > > > the request has been recycled (all content is reinitialised), in
>> > > > such a case it impossible for the webapp to retrieve the
>> > > > AsyncContext from the HttpServletRequest making the AsyncContext
>> > > > complete call impossible.
>> > > >
>> > > > Activating the tomcat logging for AsyncContext
>> > > > (org.apache.catalina.core.AsyncContextImpl.level = FINE) shows the
>> > > > recycle method is called but not the complete method, what seems to
>> > > > confirm my assumption. In a use case were the client waits for the
>> > > > response, I can see both complete and recycle are called.
>> > > >
>> > > > My question is, what is the impact of the complete not being called
>> > > > on the AsyncContext, is the socket cleaned up properly ?
>> > >
>> > > Tomcat version?
>> > >
>> > > - -chris
>> > > -BEGIN PGP SIGNATURE-
>> > > Comment: GPGTools - http://gpgtools.org
>> > > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>> > >
>> > > iQIcBAEBCAAGBQJX7CtcAAoJEBzwKT+lPKRYwekP/R1wirv0g7wJ3uR1Xk4mYIQo
>> > > jPUYBirzVcewTWrDUpOe4BdXUBzgk7zDVrOsWU9PGlc0Prwik9YHeFWlG9ItxeEs
>> > > 0ZJ0vJ1z6Od0KsxN6E8KobsE3rQu+td1Mh7d0g76zbHQKiLmrJNb8/hGuHVQr9Fd
>> > > 

Re: Async servlet and request recycling

2016-10-03 Thread Thomas Boniface
Hi,

Thanks for your feedbacks. I noticed the issue I described do not occur on
my local or integration environment. I still try to figure out how to
reproduce this in an environment I can easely update to the latest tomcat
version.

Although it may not occur in latest release. Could you give me an input on
what are the consequences of the behaviour I described ?

Thanks,
Thomas

2016-09-29 9:41 GMT+02:00 Violeta Georgieva :

> Hi,
>
> 2016-09-29 10:14 GMT+03:00 Thomas Boniface :
> >
> > The tomcat version is 7.0.64.
>
> I would recommend you to verify the behaviour against the latest Tomcat 7
> (7.0.72).
> We have changes in the async processing since 7.0.64.
> http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
>
> Regards,
> Violeta
>
> > Thomas
> >
> > 2016-09-28 22:43 GMT+02:00 Christopher Schultz <
> ch...@christopherschultz.net
> > >:
> >
> > > -BEGIN PGP SIGNED MESSAGE-
> > > Hash: SHA256
> > >
> > > Thomas,
> > >
> > > On 9/28/16 11:55 AM, Thomas Boniface wrote:
> > > > Hi,
> > > >
> > > > When a client calls an asynchronous servlet and closes the
> > > > connection a java.io.IOException: Broken pipe is catched by Tomcat
> > > > level when the webapp tries to write to the socket.
> > > >
> > > > This exception is not transmited to the webapp level but it seems
> > > > the request has been recycled (all content is reinitialised), in
> > > > such a case it impossible for the webapp to retrieve the
> > > > AsyncContext from the HttpServletRequest making the AsyncContext
> > > > complete call impossible.
> > > >
> > > > Activating the tomcat logging for AsyncContext
> > > > (org.apache.catalina.core.AsyncContextImpl.level = FINE) shows the
> > > > recycle method is called but not the complete method, what seems to
> > > > confirm my assumption. In a use case were the client waits for the
> > > > response, I can see both complete and recycle are called.
> > > >
> > > > My question is, what is the impact of the complete not being called
> > > > on the AsyncContext, is the socket cleaned up properly ?
> > >
> > > Tomcat version?
> > >
> > > - -chris
> > > -BEGIN PGP SIGNATURE-
> > > Comment: GPGTools - http://gpgtools.org
> > > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> > >
> > > iQIcBAEBCAAGBQJX7CtcAAoJEBzwKT+lPKRYwekP/R1wirv0g7wJ3uR1Xk4mYIQo
> > > jPUYBirzVcewTWrDUpOe4BdXUBzgk7zDVrOsWU9PGlc0Prwik9YHeFWlG9ItxeEs
> > > 0ZJ0vJ1z6Od0KsxN6E8KobsE3rQu+td1Mh7d0g76zbHQKiLmrJNb8/hGuHVQr9Fd
> > > M597bec0JYiQSXU+8/SMErx/bdoA8HcApaeJpnl/RuCLfYwQ5ZSS/e0SCuSqMi1W
> > > bEU0vj0pBfK6h1WuweCRoBL5Shxa2XBpbc8nlPgb7IHNlQ15dwlD10nnuYDLb7DR
> > > VmOYEx2fmynZ/fOajfTsHoWUpoHjK47vMjtLUpIXARN8LY6tR2A2iUqJ6gXlM+QL
> > > gNRkucxkI3RSV3U7ipx7y5IJTglFC7uAyFlJpPLx8gLhGWSUz+q46lDr+332kF5x
> > > VU7rKLY/3RcSJG0ZLfIzPly5tz8wssMvwu94nI8lQb4SweEJDa6cT5Z8aUUTFaf6
> > > kjy34jSgsi6QyN+NK9WKapdDNzvIo1X18zK2CqfDSeyBsgprU62o1P8R/BxIiM9f
> > > YAnK98kPtmmKyJHcS7+fBngO1/TZvsdGlYj+cXcnCNi0Fnp50WKlHOPb6wcZo5q5
> > > lcpLkwj4izmdgW8rONjMDAZj3gal7OKw0WQ/srU6XIfUa1kgR0NAtb7YQGvHJA5g
> > > ljFdLIuRnMu+43OsbSKC
> > > =zrQ5
> > > -END PGP SIGNATURE-
> > >
> > > -
> > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> > > For additional commands, e-mail: users-h...@tomcat.apache.org
> > >
> > >
>


Re: Async servlet and request recycling

2016-09-29 Thread Violeta Georgieva
Hi,

2016-09-29 10:14 GMT+03:00 Thomas Boniface :
>
> The tomcat version is 7.0.64.

I would recommend you to verify the behaviour against the latest Tomcat 7
(7.0.72).
We have changes in the async processing since 7.0.64.
http://tomcat.apache.org/tomcat-7.0-doc/changelog.html

Regards,
Violeta

> Thomas
>
> 2016-09-28 22:43 GMT+02:00 Christopher Schultz <
ch...@christopherschultz.net
> >:
>
> > -BEGIN PGP SIGNED MESSAGE-
> > Hash: SHA256
> >
> > Thomas,
> >
> > On 9/28/16 11:55 AM, Thomas Boniface wrote:
> > > Hi,
> > >
> > > When a client calls an asynchronous servlet and closes the
> > > connection a java.io.IOException: Broken pipe is catched by Tomcat
> > > level when the webapp tries to write to the socket.
> > >
> > > This exception is not transmited to the webapp level but it seems
> > > the request has been recycled (all content is reinitialised), in
> > > such a case it impossible for the webapp to retrieve the
> > > AsyncContext from the HttpServletRequest making the AsyncContext
> > > complete call impossible.
> > >
> > > Activating the tomcat logging for AsyncContext
> > > (org.apache.catalina.core.AsyncContextImpl.level = FINE) shows the
> > > recycle method is called but not the complete method, what seems to
> > > confirm my assumption. In a use case were the client waits for the
> > > response, I can see both complete and recycle are called.
> > >
> > > My question is, what is the impact of the complete not being called
> > > on the AsyncContext, is the socket cleaned up properly ?
> >
> > Tomcat version?
> >
> > - -chris
> > -BEGIN PGP SIGNATURE-
> > Comment: GPGTools - http://gpgtools.org
> > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> >
> > iQIcBAEBCAAGBQJX7CtcAAoJEBzwKT+lPKRYwekP/R1wirv0g7wJ3uR1Xk4mYIQo
> > jPUYBirzVcewTWrDUpOe4BdXUBzgk7zDVrOsWU9PGlc0Prwik9YHeFWlG9ItxeEs
> > 0ZJ0vJ1z6Od0KsxN6E8KobsE3rQu+td1Mh7d0g76zbHQKiLmrJNb8/hGuHVQr9Fd
> > M597bec0JYiQSXU+8/SMErx/bdoA8HcApaeJpnl/RuCLfYwQ5ZSS/e0SCuSqMi1W
> > bEU0vj0pBfK6h1WuweCRoBL5Shxa2XBpbc8nlPgb7IHNlQ15dwlD10nnuYDLb7DR
> > VmOYEx2fmynZ/fOajfTsHoWUpoHjK47vMjtLUpIXARN8LY6tR2A2iUqJ6gXlM+QL
> > gNRkucxkI3RSV3U7ipx7y5IJTglFC7uAyFlJpPLx8gLhGWSUz+q46lDr+332kF5x
> > VU7rKLY/3RcSJG0ZLfIzPly5tz8wssMvwu94nI8lQb4SweEJDa6cT5Z8aUUTFaf6
> > kjy34jSgsi6QyN+NK9WKapdDNzvIo1X18zK2CqfDSeyBsgprU62o1P8R/BxIiM9f
> > YAnK98kPtmmKyJHcS7+fBngO1/TZvsdGlYj+cXcnCNi0Fnp50WKlHOPb6wcZo5q5
> > lcpLkwj4izmdgW8rONjMDAZj3gal7OKw0WQ/srU6XIfUa1kgR0NAtb7YQGvHJA5g
> > ljFdLIuRnMu+43OsbSKC
> > =zrQ5
> > -END PGP SIGNATURE-
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> > For additional commands, e-mail: users-h...@tomcat.apache.org
> >
> >


Re: Async servlet and request recycling

2016-09-29 Thread Thomas Boniface
The tomcat version is 7.0.64.

Thomas

2016-09-28 22:43 GMT+02:00 Christopher Schultz :

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Thomas,
>
> On 9/28/16 11:55 AM, Thomas Boniface wrote:
> > Hi,
> >
> > When a client calls an asynchronous servlet and closes the
> > connection a java.io.IOException: Broken pipe is catched by Tomcat
> > level when the webapp tries to write to the socket.
> >
> > This exception is not transmited to the webapp level but it seems
> > the request has been recycled (all content is reinitialised), in
> > such a case it impossible for the webapp to retrieve the
> > AsyncContext from the HttpServletRequest making the AsyncContext
> > complete call impossible.
> >
> > Activating the tomcat logging for AsyncContext
> > (org.apache.catalina.core.AsyncContextImpl.level = FINE) shows the
> > recycle method is called but not the complete method, what seems to
> > confirm my assumption. In a use case were the client waits for the
> > response, I can see both complete and recycle are called.
> >
> > My question is, what is the impact of the complete not being called
> > on the AsyncContext, is the socket cleaned up properly ?
>
> Tomcat version?
>
> - -chris
> -BEGIN PGP SIGNATURE-
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCAAGBQJX7CtcAAoJEBzwKT+lPKRYwekP/R1wirv0g7wJ3uR1Xk4mYIQo
> jPUYBirzVcewTWrDUpOe4BdXUBzgk7zDVrOsWU9PGlc0Prwik9YHeFWlG9ItxeEs
> 0ZJ0vJ1z6Od0KsxN6E8KobsE3rQu+td1Mh7d0g76zbHQKiLmrJNb8/hGuHVQr9Fd
> M597bec0JYiQSXU+8/SMErx/bdoA8HcApaeJpnl/RuCLfYwQ5ZSS/e0SCuSqMi1W
> bEU0vj0pBfK6h1WuweCRoBL5Shxa2XBpbc8nlPgb7IHNlQ15dwlD10nnuYDLb7DR
> VmOYEx2fmynZ/fOajfTsHoWUpoHjK47vMjtLUpIXARN8LY6tR2A2iUqJ6gXlM+QL
> gNRkucxkI3RSV3U7ipx7y5IJTglFC7uAyFlJpPLx8gLhGWSUz+q46lDr+332kF5x
> VU7rKLY/3RcSJG0ZLfIzPly5tz8wssMvwu94nI8lQb4SweEJDa6cT5Z8aUUTFaf6
> kjy34jSgsi6QyN+NK9WKapdDNzvIo1X18zK2CqfDSeyBsgprU62o1P8R/BxIiM9f
> YAnK98kPtmmKyJHcS7+fBngO1/TZvsdGlYj+cXcnCNi0Fnp50WKlHOPb6wcZo5q5
> lcpLkwj4izmdgW8rONjMDAZj3gal7OKw0WQ/srU6XIfUa1kgR0NAtb7YQGvHJA5g
> ljFdLIuRnMu+43OsbSKC
> =zrQ5
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: Async servlet and request recycling

2016-09-28 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Thomas,

On 9/28/16 11:55 AM, Thomas Boniface wrote:
> Hi,
> 
> When a client calls an asynchronous servlet and closes the
> connection a java.io.IOException: Broken pipe is catched by Tomcat
> level when the webapp tries to write to the socket.
> 
> This exception is not transmited to the webapp level but it seems
> the request has been recycled (all content is reinitialised), in
> such a case it impossible for the webapp to retrieve the
> AsyncContext from the HttpServletRequest making the AsyncContext
> complete call impossible.
> 
> Activating the tomcat logging for AsyncContext 
> (org.apache.catalina.core.AsyncContextImpl.level = FINE) shows the
> recycle method is called but not the complete method, what seems to
> confirm my assumption. In a use case were the client waits for the
> response, I can see both complete and recycle are called.
> 
> My question is, what is the impact of the complete not being called
> on the AsyncContext, is the socket cleaned up properly ?

Tomcat version?

- -chris
-BEGIN PGP SIGNATURE-
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJX7CtcAAoJEBzwKT+lPKRYwekP/R1wirv0g7wJ3uR1Xk4mYIQo
jPUYBirzVcewTWrDUpOe4BdXUBzgk7zDVrOsWU9PGlc0Prwik9YHeFWlG9ItxeEs
0ZJ0vJ1z6Od0KsxN6E8KobsE3rQu+td1Mh7d0g76zbHQKiLmrJNb8/hGuHVQr9Fd
M597bec0JYiQSXU+8/SMErx/bdoA8HcApaeJpnl/RuCLfYwQ5ZSS/e0SCuSqMi1W
bEU0vj0pBfK6h1WuweCRoBL5Shxa2XBpbc8nlPgb7IHNlQ15dwlD10nnuYDLb7DR
VmOYEx2fmynZ/fOajfTsHoWUpoHjK47vMjtLUpIXARN8LY6tR2A2iUqJ6gXlM+QL
gNRkucxkI3RSV3U7ipx7y5IJTglFC7uAyFlJpPLx8gLhGWSUz+q46lDr+332kF5x
VU7rKLY/3RcSJG0ZLfIzPly5tz8wssMvwu94nI8lQb4SweEJDa6cT5Z8aUUTFaf6
kjy34jSgsi6QyN+NK9WKapdDNzvIo1X18zK2CqfDSeyBsgprU62o1P8R/BxIiM9f
YAnK98kPtmmKyJHcS7+fBngO1/TZvsdGlYj+cXcnCNi0Fnp50WKlHOPb6wcZo5q5
lcpLkwj4izmdgW8rONjMDAZj3gal7OKw0WQ/srU6XIfUa1kgR0NAtb7YQGvHJA5g
ljFdLIuRnMu+43OsbSKC
=zrQ5
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Async servlet and request recycling

2016-09-28 Thread Thomas Boniface
Hi,

When a client calls an asynchronous servlet and closes the connection a
java.io.IOException: Broken pipe is catched by Tomcat level when the webapp
tries to write to the socket.

This exception is not transmited to the webapp level but it seems the
request has been recycled (all content is reinitialised), in such a case it
impossible for the webapp to retrieve the AsyncContext from the
HttpServletRequest making the AsyncContext complete call impossible.

Activating the tomcat logging for AsyncContext
(org.apache.catalina.core.AsyncContextImpl.level = FINE) shows the recycle
method is called but not the complete method, what seems to confirm my
assumption. In a use case were the client waits for the response, I can see
both complete and recycle are called.

My question is, what is the impact of the complete not being called on the
AsyncContext, is the socket cleaned up properly ?

Thanks,
Thomas