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: 151
Registered: ‎03-27-2009
My Device: Not Specified

anyone have a great http thread ?

I've created my own http thread that I subclass whenever I need to make some API calls, download images, what have you.. As it's been evolving I've thrown in code to retry connections, deal with dropped connections, etc., but it's all been on the fly and isn't bulletproof. I am about to sit down and design an http connection pool system from scratch since sadly there is nothing resembling that in the SDK. Before I begin on this endevour I wonder if anyone has a class/classes they use for HTTP that they are proud of and would like to share. It would make me and future community members eternally grateful Smiley Happy

 

Regards,

Kallin Nagelberg.

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: anyone have a great http thread ?

Good luck!
Developer
Posts: 151
Registered: ‎03-27-2009
My Device: Not Specified

Re: anyone have a great http thread ?

Lol, did it sound like I was being sarcastic?

 

Seriously though, it would be such a boon to developers if RIM could include a robust http/sockets class. Otherwise you're asking every developer to reinvent the wheel. Some key features would be:

 

- A thread pool for connections that is optimized in size for the blackberry. 

- Connection timeout retries. Would be nice to have it configurable per request how many times connection should be attempted.

- A timeout mechanism on input/outputstreams, again configurable per request.

- Configurable retries on connectionClosedExceptions.

 

Thoughts?

 

 

 

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: anyone have a great http thread ?

I agree that something like this would be great. I'd also like to see support for:
  • following redirection responses (automatically and under configurable rules)
  • user interaction for authentication (maybe via call-backs on the event thread)
  • cookies
  • dispatching on response code and/or content type
I wouldn't want to implement all of this for any one particular app, as it would just add to code bloat. But a collection of classes, each packaging a subset of features, would be very useful.



Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 151
Registered: ‎03-27-2009
My Device: Not Specified

Re: anyone have a great http thread ?

Well I'd be happy to post what I end up with when I'm done, maybe get some feedback from the community.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: anyone have a great http thread ?

Don't get me wrong, I sincerely wish you good luck with this endeavor. It will be pretty complicated to build one library that satisfies the diverse needs of various projects while still working fine considering the various limited resources on a BlackBerry (e.g., thread and conneciton limit come to mind) and the open-ended nature of various I/O errors where you cannot reliably decide whether it's a transient or a permanent issue. However, it would definitely be useful to have a library like that. Some of the stuff has already been implemented by RIM in JDE v5.0.0 (see net.rim.device.api.io.transport and net.rim.device.api.io.transport.options packages).

Highlighted
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: anyone have a great http thread ?

[ Edited ]
we used the network diagnostic tool as a base for our connection tool:
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is...

for some applications it is ok, others needn't have it asynchronous and some alterations have to be made.
it is a good starting point.

another tip would be the maven package backport-util-concurrent. it uses the whole collections api, would be a bit of work to port, but would provide a great utility on the blackberry.
http://backport-jsr166.sourceforge.net/
http://dcl.mathcs.emory.edu/php/loadPage.php?content=/util/overview.html
Message Edited by simon_hain on 09-22-2009 11:33 AM
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter