I have some code to connect to the internet, it works fine in the simulator
but when I try it on a real device, I always get a 400 http response code
(the response body says “Connection timed out”)
I’m using JRE 5
and using Blackberry 9000 on OS version 5 for both the real device and the simulator.
It is activated according to Advanced Options > Enterprise Activation
Is there something else I need to change on the real device to make it work?
I slowly whittled down my code to get to the root of the issue
and I’m down to this code:
package mypackage;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import net.rim.device.api.io.transport.TransportInfo;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;
public class MyApp extends UiApplication {
public static void main(String[] args) {
MyApp theApp = new MyApp();
theApp.enterEventDispatcher();
}
public MyApp() {
pushScreen(new SimpleScreen());
}
}
class SimpleScreen extends MainScreen {
public SimpleScreen() {
this.setTitle("Hello");
ConnectionThread ct = new ConnectionThread();
ct.start();
}
}
class ConnectionThread extends Thread {
private static String url = "http://www.wikipedia.org/";
public void run() {
System.out.println(" -- ConnectionThread.run()");
System.out.println(" ---- MDS hasSufficientCoverage? " + TransportInfo.hasSufficientCoverage(TransportInfo.TRANSPORT_MDS));
try {
HttpConnection httpConn;
httpConn = (HttpConnection) Connector.open(url);
final int iResponseCode = httpConn.getResponseCode();
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
Dialog.alert("Response code: " + Integer.toString(iResponseCode));
}
});
} catch (Exception e) {
System.err.println("Caught IOException: " + e.getMessage());
}
System.out.println(" -- /ConnectionThread.run()");
}
}
==============================================
// EDIT:
I’m pretty sure its a device config issue now, I just the Network Diagnostic Tool and it also returns a 400 HTTP Response with the message “connect timed out”.
==============================================
//EDIT #2:
I just tried options->mobile network->diagnostics test
Here are the results:
ICMP Ping Echo: No
------
Blackberry Registration: Yes
Connected to Blackberry: Yes
Blackberry PIN-PIN: Yes
------
Server Name: <my enterprise server>
Email Address: <my email>
Connected to <my email>: Yes
Then I tried options->mobile network->tools->ping
and pinged google and wikipedia and both say A network error occurred
I asked the BES Admin and he says its Docomo issue.. and he has taken it up with them.
Basically there’s no code problem (as far as I can tell)