Hi All,

I was wondering if you had any thoughts to some errors I am getting with 
Java I/O.

Here is my setup:  I have 4 Android phones in an Ad-Hoc WIFI network.  Each 
of these Android phones is running a Jetty Webserver 
(http://jetty.codehaus.org/jetty/).  Jetty has an app specifically for 
Android, but I believe that is not what I want, so what I did was actually 
just download the Jetty JAR, and put it in the build-path of my Android 
project.  So.., each of the 4 phones is running a Jetty Webserver.  The 
Webserver is capable of processing HTTP GET and HTTP POST commands.  The 
HTTP GET is used by phones to get files from other phones, and the POST is 
used to POST XML commands that essentially command a phone to do something. 
 So.., this all seems to be working fine.

Now, I'm starting to transfer a lot of files between phones.  More 
specifically in my setup, 1 phone is serving 450 image files that the other 
3 phones are trying to get using the HTTP GET commands.  Each phone that is 
requesting files basically has a list of URL's that it does HTTP GET on to 
get files, and there is no delay (like Thread.sleep) between when a HTTP 
GET ends and the next one is processed.  The reason for stating the point 
of there being no delay between when the first HTTP GET ends and the next 
HTTP GET starts is that the phone that is serving the 450 files is getting 
pegged pretty hard by HTTP GET requests.  

I've noticed the following JavaI/O errors while doing this:

*04-17 22:48:59.183: W/System.err(31530): java.io.IOException: Closed
04-17 22:48:59.183: W/System.err(31530): at 
org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:152)
04-17 22:48:59.183: W/System.err(31530): at 
org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:101)
04-17 22:48:59.187: W/System.err(31530): at 
java.io.BufferedOutputStream.write(BufferedOutputStream.java:129)
04-17 22:48:59.187: W/System.err(31530): at 
org.kiran.ms.core.WebserverHandler.processHTTPGet(WebserverHandler.java:125)
04-17 22:48:59.187: W/System.err(31530): at 
org.kiran.ms.core.WebserverHandler.handle(WebserverHandler.java:86)
04-17 22:48:59.187: W/System.err(31530): at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
04-17 22:48:59.187: W/System.err(31530): at 
org.eclipse.jetty.server.Server.handle(Server.java:346)
04-17 22:48:59.187: W/System.err(31530): at 
org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442)
04-17 22:48:59.187: W/System.err(31530): at 
org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)
04-17 22:48:59.187: W/System.err(31530): at 
org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582)
04-17 22:48:59.187: W/System.err(31530): at 
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)
04-17 22:48:59.187: W/System.err(31530): at 
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)
04-17 22:48:59.187: W/System.err(31530): at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)
04-17 22:48:59.187: W/System.err(31530): at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)
04-17 22:48:59.187: W/System.err(31530): at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
04-17 22:48:59.187: W/System.err(31530): at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
04-17 22:48:59.187: W/System.err(31530): at 
java.lang.Thread.run(Thread.java:1019)*

*04-17 22:49:36.722: W/System.err(31530): java.lang.IllegalStateException: 
State==HEADER*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:824)*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.http.AbstractGenerator.blockForOutput(AbstractGenerator.java:541)
*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:159)*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:101)*
*04-17 22:49:36.722: W/System.err(31530):  at 
java.io.BufferedOutputStream.write(BufferedOutputStream.java:129)*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.kiran.ms.core.WebserverHandler.processHTTPGet(WebserverHandler.java:125)
*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.kiran.ms.core.WebserverHandler.handle(WebserverHandler.java:86)*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.server.Server.handle(Server.java:346)*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442)
*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)
*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582)*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)
*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)
*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)
*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
*
*04-17 22:49:36.722: W/System.err(31530):  at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
*
*04-17 22:49:36.722: W/System.err(31530):  at 
java.lang.Thread.run(Thread.java:1019)*

These errors are popping up occasionally while Jetty is trying to serve a 
specific file but I don't think the error is file specific (i.e. the same 
errors pop up with different files at different times), and I'm thinking 
the errors have something to do with the OS not being able to read these 
files fast enough?

The code I'm using to process execute a HTTP GET is (the relavent portion 
of the code):

BufferedInputStream bis = null;
OutputStream outStream = null;
try {
HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet();
        request.setURI(new URI(getURL));
        HttpResponse response = client.execute(request);
        
        bis = new BufferedInputStream(response.getEntity().getContent());
        outStream = new FileOutputStream(fullPath);
        
        bytesRead = bis.read(buf1, 0, bufLen);
while (bytesRead != -1) {
outStream.write(buf1, 0, bytesRead);
bytesRead = bis.read(buf1, 0, bufLen);
}
}

Thanks in advance,
Kiran

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to