We have done a series of tests and have determined a failure mode in the
J2ME HTTP network functionality on this phone:
Firmware: V 2.54, 2-3-2003
Network: AT&T
Using the published code from the networking example at:
http://wireless.java.sun.com/midp/articles/network/
(Example 3)
Repeating the connection in a loop we see the following replicable
behavior:
1. Network requests work fine till around the 13th interaction.
2. This request tends to throw an exception. (i.e. unexpected
end-of-stream encountered)
3. We believe this exception is caused by a network timeout based on our
other tests.
4. The 14th request is then successful but the 15th request also times
out.
5. At this point we appear to have lost the ability to do any net
connection as our 16th, 17th, 18th, 19th, 20th (and so on) requests all
throw exceptions.
We were able to reproduce and verify this problem with the commercial
product 'WebViewer" on the Nokia 3650 described below.
http://reqwireless.com/webviewer.html
Same behavior ... as the test below. After about 10-13 "I/O requests" we
get the -33 exception ... then one success ... then "no joy".
We did this via. the "Reload Page" operation and verified that indeed
... the software was reloading the page from the browser (we created a
very small HTML page with one word).
We even alternated between two seperate URL's on the theory that the WAP
Gateway was somehow the culprit ... but the behavior was identical.
------------------------------------------------
Example Code Follows:
package thirdexample;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
/**
* An example MIDlet to invoke a CGI script.
*/
public class ThirdExample extends MIDlet
{
private Display display;
String url =
"http://developer.java.sun.com/cgibin/getgrade.cgi?name=182016";
private Form fForm;
public ThirdExample()
{
display = Display.getDisplay(this);
}
/**
* Initialization. Invoked the MIDlet is activated.
*/
public void startApp()
{
fForm = new Form("Test");
display.setCurrent(fForm);
for (int i = 0; i < 20; i++)
{
fForm.append("try #" + (i + 1) + ": ");
try
{
long time1 = System.currentTimeMillis();
getGrade(url);
long time2 = System.currentTimeMillis();
fForm.append("(" + (time2 - time1) + " millis)\n");
}
catch (IOException e)
{
fForm.append(e.getMessage());
e.printStackTrace();
}
}
}
/**
* Pause, discontinue ....
*/
public void pauseApp() { }
/**
* Destroy must cleanup everything.
*/
public void destroyApp(boolean unconditional) { }
/**
* Retrieve a grade....
*/
void getGrade(String url) throws IOException
{
HttpConnection c = null;
InputStream is = null;
OutputStream os = null;
StringBuffer b = new StringBuffer();
TextBox t = null;
try
{
c = (HttpConnection) Connector.open(url);
c.setRequestMethod(HttpConnection.GET);
c.setRequestProperty("IF-Modified-Since",
"10 Nov 2000 17:29:12 GMT");
c.setRequestProperty("User-Agent",
"Profile/MIDP-1.0
Confirguration/CLDC-1.0");
c.setRequestProperty("Content-Language",
"en-CA");
os = c.openOutputStream();
/**
String str = "?idnum=182016";
byte postmsg[] = str.getBytes();
for(int i=0;i<postmsg.length;i++) {
os.writeByte(postmsg[i]);
}
os.flush();
*/
is = c.openDataInputStream();
int ch;
while ((ch = is.read()) != -1)
{
b.append((char) ch);
}
//t = new TextBox("Final Grades", b.toString(), 1024, 0);
fForm.append(b.toString());
}
finally
{
if (is != null)
{
is.close();
}
if (os != null)
{
os.close();
}
if (c != null)
{
c.close();
}
}
//display.setCurrent(t);
}
}
This code has been successfully tested in the emulator and on other
phones.
Received on Mon Jul 7 07:07:35 2003