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
ro27
Posts: 8
Registered: ‎03-30-2011
My Device: Blackberry Bold 9700
My Carrier: O2

Multiple HTTP operations in one program

I'm making an app that used the Blackberry Player library, and I run it on a seperate thread. I also do HTTP requests within my app for different things. My problem is that even though the player is on its own thread, it blocks all my HTTP requests, so the program will hang until the song ends (if the user tries to access a different screen that uses a new HTTP request). Anyone any idea why? I use the Blackberry Simulator with the MDS simulator. Unfortunately I can't try it on my phone, but I can't see why that'd make a difference.

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Multiple HTTP operations in one program

Are the HTTP requets also in a separate thread (not the event thread)?

 

 

Please use plain text.
New Contributor
ro27
Posts: 8
Registered: ‎03-30-2011
My Device: Blackberry Bold 9700
My Carrier: O2

Re: Multiple HTTP operations in one program

They're in the event thread. Is that a problem?

Please use plain text.
Developer
jprofitt
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: Multiple HTTP operations in one program

You should never put a HttpConnection in the event thread because it will block everything until it completes. Try putting all of them in their own threads and see if that fixes your problem.

Please use plain text.
New Contributor
ro27
Posts: 8
Registered: ‎03-30-2011
My Device: Blackberry Bold 9700
My Carrier: O2

Re: Multiple HTTP operations in one program

The problem is not that the UI freezes until it completes, rather that the request never completes (though it would were the player thread not running). I've moved the HTTP request to a separate thread but it still does the same thing. Any more ideas? It's like theres a limit to one HTTP request thread or something.

Please use plain text.
Developer
dx22
Posts: 402
Registered: ‎11-26-2010
My Device: Torch

Re: Multiple HTTP operations in one program

Make sure the server you connect to is actually available.

----------------------------------------------------------------------
Press the button to give kudos if I helped you :smileyhappy:
Please use plain text.
Developer
jprofitt
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: Multiple HTTP operations in one program

Can you let us see how you're creating these calls?

Please use plain text.
New Contributor
ro27
Posts: 8
Registered: ‎03-30-2011
My Device: Blackberry Bold 9700
My Carrier: O2

Re: Multiple HTTP operations in one program

I'm doing:

 

player = Manager.createPlayer(url);

 

 

In a method in a PlayerThread, which does this when it is started.

 

And for the actual HTTP request (which is definitely connectable, as it works as soon as the song finishes):

 

c =  HttpUtils.makeHttpConnection(url, null, null, 0);

 Which is also in it's own thread.

 

Please use plain text.
Developer
dx22
Posts: 402
Registered: ‎11-26-2010
My Device: Torch

Re: Multiple HTTP operations in one program

There isn't a HttpUtils class. Tell us what does HttpUtils.makeHttpConnection do?

----------------------------------------------------------------------
Press the button to give kudos if I helped you :smileyhappy:
Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Multiple HTTP operations in one program

To answer an earlier question, connection limits are documented here:

http://supportforums.blackberry.com/t5/Java-Development/Maximum-number-of-simultaneous-connections/t...

 

I would recommend a download server, a single Thread than handles all the downloads, rather than initiating a Thread for each download. 

Please use plain text.