Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
icchan
Posts: 6
Registered: ‎07-22-2011
My Device: 9000

Help using MDS to connect to the Internet on a real device (works in simulator)

[ Edited ]

Hello,

 

I have some code to connect to the internet, it works fine in the simulator over MDS

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 OS5 for both the real device and the simulator.

 

Is there something I need to change on the real device to make it work?

It is activated according to Advanced Options > Enterprise Activation

 

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()");
		}
	}

 

New Contributor
icchan
Posts: 6
Registered: ‎07-22-2011
My Device: 9000

Re: Help using MDS to connect to the Internet on a real device (works in simulator)

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".

Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Help using MDS to connect to the Internet on a real device (works in simulator)

Try using the Browser on the device.  If are running a pre OS 6.0 device, you want to make 100% sure it is using the BlackBerry Browser, and not the HotSpot Browser or the WAP Browser.  Check Options-->Advanced-->Default Browser. 

Contributor
paabs
Posts: 41
Registered: ‎07-20-2011
My Device: BlackBeery 9800

Re: Help using MDS to connect to the Internet on a real device (works in simulator)

Hi,

I am newbie to blackberry application development and I tried to run the same program in my simulator over MDS, but its not working. Can anyone tell me why its not working?

Thanks in advance.

Thanks & Regards,
Paabs
New Contributor
icchan
Posts: 6
Registered: ‎07-22-2011
My Device: 9000

Re: Help using MDS to connect to the Internet on a real device (works in simulator)

[ Edited ]

Hi, thanks for your reply.

I just checked and the selected option for
"Default browser configuration" says "Internet Browser"

and
"Default MDS browser configuration" also says "Internet Browser"

neither of them has the option for "Blackberry Browser"

 

-----------------------------------------

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`

Developer
johnbibs
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800

Re: Help using MDS to connect to the Internet on a real device (works in simulator)

hi icchan,

since you mentioned that it is activated in "Enterprise Activation", you are a BES user.

Have you tried browsing using the internet Browser? Also double check with your BES Administrator if they've set the policy to not to allow selected devices to connect to the internet.


New Contributor
icchan
Posts: 6
Registered: ‎07-22-2011
My Device: 9000

Re: Help using MDS to connect to the Internet on a real device (works in simulator)

Hi, thanks for your reply.

Sorry, I did try my surfing to a couple of websites in the browser and it works fine.

I dont know much about BES, so what should I be asking about? MDS log files? internet security policies?

I dont wanna be "that guy" who goes to the admin and says "its broken, fix it"
Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Help using MDS to connect to the Internet on a real device (works in simulator)

AFAIK, Internet browser is the BIS-b Browser.  if it is does not include BlackBerry Browser, then you are not on a BES device and that would explain your problem.  In my experie3nce, if you try ";deviceside=false" on later OS's, when the device does not have MDS connection, there is an exception thrown, that says the URL is invalid.  This is not correct really, as it is the connection suffix that is invalid.  But this is another clue that in fact you do not have a BES device. 

New Contributor
icchan
Posts: 6
Registered: ‎07-22-2011
My Device: 9000

Re: Help using MDS to connect to the Internet on a real device (works in simulator)

[ Edited ]

When using ";deviceside=false"  i still get a 400 http response (no exception thrown)

 

I just tried the same code on a blackberry 9630 I just got (definitely not BES activated) and it does indeed throw an exception. (invalid url parameter)

 

Does that imply that my first device is BES?

 

both devices are on  v5.0

 

//EDIT

 

I activated the new device and tried the Network Diagnostics app..  and when attempting a MDS connection i get an IOException "Failed to transmit"

Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Help using MDS to connect to the Internet on a real device (works in simulator)

What device and what OS level is the device you are getting a 400 on?

 

I think that this is an indication you are on a BES device.