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 Developer
mobaladje
Posts: 10
Registered: ‎10-07-2008
My Device: Not Specified

[Bold][HttpConnection]Unable to establish WiFi connection

Hello.

I try to establish WiFi connection on a BlackBerry Bold (OS 4.6.0.89) but it does not work. 

 

HttpConnection connection = (HttpConnection) Connector.open(url + ";interface=wifi", Connector.READ);

This code throws an IOException.

I try ";deviceside=true;interface=wifi", but it throws the same exception.

There's no SIM in the device and I can reach the url with the browser.

 

On a 8120, It works the first times but after a momentit throws a DNSException. When it happens, it's impossible to reach the url with the browser.

 

Have you got any idea ?

Thanks a lot.

 

 

 

 

 

New Developer
mobaladje
Posts: 10
Registered: ‎10-07-2008
My Device: Not Specified

Re: [Bold][HttpConnection]Unable to establish WiFi connection

I have made of lot of tests but nothing works.

Can someone help ?

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

Re: [Bold][HttpConnection]Unable to establish WiFi connection

I have just successfully used a Bold with no SIM to connect using WiFi.

 

The application is compiled using JDE 4.1, the http connection code looks like:

c = (HttpConnection)Connector.open(_connectionURL);

 

I note according to the Javadoc, that IOException will be thrown by this if you there is a Firewall problem.  I suggest you reset your Firewall and try again.

Options--> Security-->Firewall, then use the menu to "Reset Settings".

 

Hope this helps.

New Developer
mobaladje
Posts: 10
Registered: ‎10-07-2008
My Device: Not Specified

Re: [Bold][HttpConnection]Unable to establish WiFi connection

Hello.

I have a new Wi-FI connection problem.

I try to connect using that url : http://www.google.com;interface=wifi

I get that error : java.io.IOException

 

I do my test an a Bold with the mobile connection off and Wi-Fi on and well configured.

I can browse Internet with the Blackberry Browser.

When I go to Options > Advanced Options > Browser. In "default browser  configuration, I have only 1 option : "Hotspot Browser". I don't know if it's usefull for my problem.

 

Thanks a lot.

Regards.

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

Re: [Bold][HttpConnection]Unable to establish WiFi connection

What is the text associated with the IOException?  Have you reset the Firewall as per presious post?  Is your applciatin signed?  What level JDE did you use to develop the app?  Is the request being issued from a background thread

New Developer
mobaladje
Posts: 10
Registered: ‎10-07-2008
My Device: Not Specified

Re: [Bold][HttpConnection]Unable to establish WiFi connection

Firewall : off

JDE : 4.2.1

Application : signed

The request is issued from a background thread.

New Developer
mobaladje
Posts: 10
Registered: ‎10-07-2008
My Device: Not Specified

Re: [Bold][HttpConnection]Unable to establish WiFi connection

In fact, the exception is thrown by this line :

int rc = connection.getResponseCode(); 

 

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

Re: [Bold][HttpConnection]Unable to establish WiFi connection

And what is the text (toString())?
New Developer
mobaladje
Posts: 10
Registered: ‎10-07-2008
My Device: Not Specified

Re: [Bold][HttpConnection]Unable to establish WiFi connection

The text is : java.io.IOException: Connection not writeable

 

I found the real problem.

I do :

 

HttpConnection connection = (HttpConnection) Connector.open(url, Connector.READ ); int res = connection.getResponseCode();

 

It doesn't work. But if I do :

 

HttpConnection connection = (HttpConnection) Connector.open(url); int res = connection.getResponseCode();

It works.

 

For me, the default mode was Connector.READ. But it seems there's a difference between Connector.open(url) and  Connector.open(url,Connector.READ).

 

 

 

Developer
davidmccormack
Posts: 168
Registered: ‎11-01-2008
My Device: Galaxy S II

Re: [Bold][HttpConnection]Unable to establish WiFi connection

HTTP connections have to be read/write - even GET requests. The reason, presumably, is that data must be written to the underlying socket in order to send the request up to the server. The exception is thrown on calling HttpConnection.getResponseCode() because it is only at that point that data is actually sent up to the server. The call to Connector.open() just opens the socket but doesn't transmit any data.