Hi,

I'm trying to connect to a server using Connector.open("..."). When executing "rc = conn.getResponseCode();" i get an IOException with the text "Symbian OS error = -4155". A code snippet is attached below.

I am using a nokia 6600. It takes some seconds within getResponseCode(), until the exception is thrown. It happens after i get the dialog box asking me if the midlet is allowed to communicate over the network. Neighter The GPRS symbol, nor the dialog box for access point selection get displayed before the exception is thrown.

In the Series_60_MIDP_Concept_SDK_Beta_0_3_1_Nokia_edition emulator i get an IOException with the text "Error initializing channel connection HTTP/1.1 400 Bad Request" at the same line.

In the Series_60_MIDP_SDK_2_1_Beta emulator i get an IOException with the text "System error", also at the same line.

What am I doing wrong?

Thanks in advance for any hints! This is pretty urgent, as my next days of work rely on it!

Mihai



My source code:

HttpConnection conn = null;
InputStream is = null;
int rc;

try {
conn = (HttpConnection)Connector.open("http://www.google.de");
// Getting the response code will open the connection,
// send the request, and read the HTTP response headers.
// The headers are stored until requested.
rc = conn.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
throw new IOException("HTTP response code: " + rc);
}

is = conn.openInputStream();
// Get the ContentType
String type = conn.getType();
// Get the length and process the data
int len = (int)conn.getLength();
if (len > 0) {
int actual = 0;
int bytesread = 0 ;
byte[] data = new byte[len];
while ((bytesread != len) && (actual != -1)) {
actual = is.read(data, bytesread, len - bytesread);
bytesread += actual;
}
} else {
int ch;
while ((ch = is.read()) != -1) {
//append("" + ch,null);
}
}
} catch (ClassCastException e) {
throw new IllegalArgumentException("Not an HTTP URL");
} finally {
if (is != null)
is.close();
if (conn != null)
conn.close();
}