This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Embedded Tomcat 7 problem: concurrent requests lead to Fatal transport error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Embedded Tomcat 7 problem: concurrent requests lead to Fatal transport error" Watch "Embedded Tomcat 7 problem: concurrent requests lead to Fatal transport error" New topic
Author

Embedded Tomcat 7 problem: concurrent requests lead to Fatal transport error

Yuhong Qian
Greenhorn

Joined: Jan 18, 2010
Posts: 5
Hi all,

I am using Embedded Tomcat 7 in my java application. The request url to Embedded Tomcat is http://localhost:8091/GetAgentServlet?groupId=1. It works fine if the request is submitted one by one, but excpetion occurred when multiple requests (above 4, for example) are submited simultaneously.

How to solve this problem? Is there any way to configure the concurrent thread number or something?
Any help are highly appreciated.

Fatal transport error: Stream closed
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162)
at java.io.BufferedInputStream.read(BufferedInputStream.java:258)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at ictbox.agi.HttpClientOp.getAgentServlet(HttpClientOp.java:97)
at AutoDialerAgi.service(AutoDialerAgi.java:104)
at org.asteriskjava.fastagi.internal.AgiConnectionHandler.runScript(AgiConnectionHandler.java:144)
at org.asteriskjava.fastagi.internal.AgiConnectionHandler.run(AgiConnectionHandler.java:116)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)



Lucy
Yuhong Qian
Greenhorn

Joined: Jan 18, 2010
Posts: 5
hi,

I am using HTTPClient to access the url ( See the above) , I have been
facing an Intermittent problem with the following exception. Is it a problem with the HTTPClient or a problem with the Embbedded Tomcat?

Fatal transport error: Stream closed
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162)
at java.io.BufferedInputStream.read(BufferedInputStream.java:258)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at ictbox.agi.HttpClientOp.getAgentServlet(HttpClientOp.java:97)
at AutoDialerAgi.service(AutoDialerAgi.java:104)
at org.asteriskjava.fastagi.internal.AgiConnectionHandler.runScript(AgiConnectionHandler.java:144)
at org.asteriskjava.fastagi.internal.AgiConnectionHandler.run(AgiConnectionHandler.java:116)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)

Lucy
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17046
    
  26

Welcome to the JavaRanch, Lucy!

Tomcat doesn't really care what apps do as network clients, allowing for the fact that they should do it relatively quickly and not leave stuff hanging when the request has completed processing (that is, don't spawn child threads and so forth).

Although it's possible that you're having a problem with the data coming back from the remote server, it sounds like your servlet isn't thread-safe. If you are keeping any information in static or class-member variables, they can and will be corrupted when multiple requests are all being handled by the same servlet.


An IDE is no substitute for an Intelligent Developer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Embedded Tomcat 7 problem: concurrent requests lead to Fatal transport error
 
It's not a secret anymore!