http connection not working on phone

Hi i am trying to connect to a http server using the new nokia n95 phone with T-mobile web and walk(Unlimited 3g internet access)

on the emulaor and on the phones wifi connection, it works. But when i try connecting to the server using gprs/3g it doesnt. The response code never equals to OK . here is my code below:

I know it is not working because has soon as the program makes an attempted to connect, the root.notifyDestroy() closes the application as i expect it too

server = (HttpConnection) Connector.open(url);

server.setRequestMethod(HttpConnection.POST);

int rc = server.getResponseCode();

if (rc == HttpConnection.HTTP_OK)

{

is = server.openInputStream();

}

else

{

root.notifyDestroyed();

Alert alert =new Alert ("Error");

alert.setString("Error, server is down");

alert.setTimeout (5000);

Display.getDisplay(root).setCurrent(alert);

thrownew IOException("HTTP response code: " + rc);

}

[1392 byte] By [jonney69a] at [2007-11-27 4:06:49]
# 1
Have you checked your GPRS settings on your device?Does getResponseCode return an actual value or does it throw an exception?
jonathan.lea at 2007-7-12 9:11:59 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

its hard to tell has i cant debug from the phone device. Al i can say is that the response code is not equal to OK.

I have checked my gprs settings and there is nothingw rong on it as far as ic an see because i can browse the web and use other programs like FRING to access the web

Its strange because on the emulator and on a wifi connection from the phone it works! Can anybody give me some ideas on why it is not working?

jonney69a at 2007-7-12 9:11:59 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
hi doesnt anyone here have any ideas on why my application won connect to a http server please? im sure someone here can lend a hand, thanks
jonney69a at 2007-7-12 9:11:59 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
bump can anyone help me please? i have found out what the response code is of my connection, its a HTTP_MOVED_TEMP response! what does this mean and how can i fix it? from the API its not very clear what it is and hwo to fix it
jonney69a at 2007-7-12 9:11:59 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5

I had all sorts of strange problems getting http connect to work from phones. Most of my problems were resolved by adding every single header I could find that tells the carrier's gateway to leave it alone. Try adding these headers to the connection from the phone, and the response from the server:

connection.setRequestProperty( "User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");

connection.setRequestProperty( "Content-Type", "application/octet-stream");

connection.setRequestProperty( "Content-Length", ""+(allContentToSend.length));

connection.setRequestProperty( "Cache-Control","no-store");

connection.setRequestProperty( "Cache-Control", "no-cache");

connection.setRequestProperty( "Pragma","no-cache");

connection.setRequestProperty( "Cache-Control", "no-transform");

connection.setRequestProperty( "Connection", "Keep-Alive");

connection.setRequestProperty( "Proxy-Connection", "Keep-Alive");

The content-type will depend on what you are sending. octet-stream is for binary data. If you are just encoding parameters in your POST you may need something else like "application/x-www-form-urlencoded".

The content-length is obviously dependant on what you are sending. The rest of the properties simply tell whoever is transporting the request to leave it alone.

TEMP_MOVED sounds like a redirect or some odd thing. Maybe the carrier is caching the response, and you are actually getting something unnexpected.

Hope this helps.

hooblea at 2007-7-12 9:11:59 > top of Java-index,Java Mobility Forums,Java ME Technologies...