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
Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: IOException in connection creation

Hi,
I just took another look at your code and saw that your connections are properly closed.
The closeConnection should always be called in a finally block.
Again, this might not be the cause of your problem and we need the error's details to verify that.
E.
Trusted Contributor
Posts: 145
Registered: ‎05-01-2011
My Device: 9780
My Carrier: Developer

Re: IOException in connection creation

[ Edited ]

Yesterday I left the app in open state (By pressing red end key) @ 8PM and today after 14 hours (in this time no one touch the device), around 10 AM  open my app and press an item and I got the network exception error, but this is for the first hit only. After that i dint change any settings or anything jus try one more time but everything works fine.

 

When I check the log file:

 

Around 9:58AM: d podcassts - coverageStatusChanged: newCoverage: 0

 

and the url in the log file http://10.0.1.5:6070/middletier-web/news.do?

 

Java Exception - IOException - Detail - APN is not specified

 

d podcassts - coverageStatusChanged: newCoverage: 1

 

and the url in the log file http://10.0.1.5:6070/middletier-web/news.do;interface=wifi

 

 

for the first hit only device was not able to open the tcp socket but after that it was able to open the tcp socket over wifi

 

and from the log for the first hit the appended strings are not get printed (i.e., either ;interface=wifi or ;deviceside=true) etc.,

Trusted Contributor
Posts: 145
Registered: ‎05-01-2011
My Device: 9780
My Carrier: Developer

Re: IOException in connection creation

[ Edited ]

After a very long hours of keeping the phone idle the network not get refreshed or is it the device behavior?

 

Since I've written in my code using RIM's transport detective to detect the coverage availability either wifi or wap2 but the connectionstring parameter is not get appended for the first time means there is no coverage availability in my device (eventhough i've connected with wifi) right?

 

I ll do a retry in my code, but how can I refresh the wifi network each & every time? is there any possibility for that?

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

Re: IOException in connection creation

I'm guessing that your phone went into idle and to save battery, it shutdown the WiFi network, so the code chose direct TCP but you don't have the APN parameters set to actually use that method, even though it is available. 

 

Later the WiFi kicked back in and your mechanism went back to WiFi.

 

This is working correctly.  It is not doing what you want I guess, so you need to think about how you handle this.

 

Because if this sort of confusion, I generally recommend that you try to find a connection method that works, and stick to it.  If there is a problem, try to find another one, but don't swap to it until you are sure it works.  Also give the user the option to re-test.  I think this is more complicated to implement but simpler for the users.  In this case when they retried and WiFi was not available, you would just say " WiFi not available, do you want me to try to connect another way?"

 

I don't use ConnectionFactory for this reason.

Trusted Contributor
Posts: 145
Registered: ‎05-01-2011
My Device: 9780
My Carrier: Developer

Re: IOException in connection creation

What else are you using instead of connection factory?

 

find a connection method that works, and stick to it.  If there is a problem, try to find another one - What do you mean here - In that class itself am looking for wap2 if that is not available then looking for wifi?

 

Please explain me in detail how to handle this or an alternate solution for this problem

 

Normally I thought the developers would use this Connector.open(url) for connection creations?

Facing a lot of connection related issues everyday

 

Also am developing in OS 4.5

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

Re: IOException in connection creation

ConnectionFactory is OS 5.0.  So doesn't apply.

 

There is nothing wrong with your code.

 

I was suggesting that you only test the options available at set-up time, or when the connection tried fails.  Once you have found a connection method that works, record that somewhere and use it by default in future rather than checking the options again.  I just find this easier to manage.  How you change your class to manage this is up to you - if in fact, you think it is a good idea.

 

The real issue you have had with this problem is that you did not know what connection was being used, nor did you know what the actual exception was.  You need these bits of information (and the carrier and sometimes the user's plan details, and sometimes the header fields on the http response - see here: http://supportforums.blackberry.com/t5/Java-Development/Alternate-for-HttpClient/td-p/1456591) to analyze BlackBerry networking problems.  I hope you have changed your connection code to collect this sort of information and report it so your users can help you find their connection problems in the future. 

Trusted Contributor
Posts: 145
Registered: ‎05-01-2011
My Device: 9780
My Carrier: Developer

Re: IOException in connection creation

Also if wifi is not available then how browser is working, Are they using the direct tcp?

 

Do I have to check out for TRANSPORT_TCP_CELLULAR and append the connectionstring with ;deviceside=true

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

Re: IOException in connection creation

The questions you are asking are commonly asked on this forum.

 

The short answers are:

a) The Browser is using BIS-B, which you probably do not have access to

b) Making direct TCP carrier agnostic is a dream at the moment, the best you can do is ask the user to input the APN settings for their carrier or have some special built-in conversion that will create the connection APN parameters for direct TCP.

 

I suggest some further reading to get more detailed answers youself including:

1) Type network on the search button and review the videos

2) http://docs.blackberry.com/en/developers/deliverables/36653/Network_connections_1289656_11.jsp

3) http://supportforums.blackberry.com/t5/Java-Development/Connecting-your-BlackBerry-http-and-socket-c...

4) http://supportforums.blackberry.com/t5/Java-Development/Sample-HTTP-Connection-code-and-BIS-B-Access...

 

I'm still learning.  Recently I had connection code that has been working for years break because of a parental lock that some mobile network put on.....

Trusted Contributor
Posts: 145
Registered: ‎05-01-2011
My Device: 9780
My Carrier: Developer

Re: IOException in connection creation

Thank you very much for your most valuable replies

 

Am searching how to use the direct TCP

 

 

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified