BlackBerryForums.com : Your Number One BlackBerry Community   TaskMaster for BlackBerry   

»Sponsored Links



Closed Thread
 
LinkBack Thread Tools
  (#1 (permalink)) Old
consilient_sam Offline
New Member
 
Posts: 3
Join Date: Oct 2005
Location: St. John's
Model: 7100r
Default HttpConnection hanging on Connector.open() call - 10-26-2005, 12:50 PM

Hey, I'm new here but have searched through the forums on occasion and decided posting could be helpful.

A little about myself first....

I'm a software developer with a Company called Consilient Technologies in St. John's, NL Canada (i've noticed one of our ads in the banner at the top of the page) and I have a Bachelors degree in Computer Science. I've been working on our client/server code for sometime now.

So here is the situation:

Our blackberry client software connects to our server with an HttpConnection (usually through https - we have certificates and all that jazz) and for the majority of the time this works lovely. But sometimes the Connector.open() call will hang indefinately. This doesn't occur in the simulator. I have also just recently re-written our transport code to use Sockets to see if using the lower level objects would be of any help - same issue still occurs. I'll post the code in question below. I'm not expecting any revelations from anyone, but i'm at the end of my rope.

Code:
connection = (HttpConnection) Connector.open(hostName, Connector.READ_WRITE, true);
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty(PROP_CONTENT_TYPE, contentType);
connection.setRequestProperty(PROP_CONTENT_LENGTH, String.valueOf(bytesToSend.length));
connection.setRequestProperty(PROP_CONNECTION, "Close");
String locale  = System.getProperty(PROP_MICROEDITION_LOCALE);
if (locale != null) 
{
    connection.setRequestProperty(PROP_CONTENT_LANGUAGE, locale);
}
// write the client request to the OS
os = connection.openOutputStream();
os.write(bytesToSend); 
os.flush();

// read all data from the input stream
is = connection.openInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int numRead = 0;
byte[] buffer = new byte[256];
while ((numRead = is.read(buffer)) != -1)
{
   baos.write(buffer, 0, numRead);
}
Thanks for any help
   
Sponsored Links
Please Login or Register to Remove these Advertisements!

  (#2 (permalink)) Old
consilient_sam Offline
New Member
 
Posts: 3
Join Date: Oct 2005
Location: St. John's
Model: 7100r
Default 10-28-2005, 01:16 PM

So i wasn't expecting much response, but we've been doing some more testing and it seems that if a midlet does not close it's streams/connections there are only ~7 connections available (a connection pool perhaps). So even if a seperate midlet tries to create connections, you get MaxConnections exceptions. Does anyone know of a sure-fire way to ensure that connections are always closed (besides doing the close() call in a finally block and surrounding the close's with try/catch statements)?
   
  (#3 (permalink)) Old
jonberry Offline
Thumbs Must Hurt
 
Posts: 142
Join Date: Apr 2005
Model: 950
Carrier: T-Mobile
Default 10-28-2005, 03:04 PM

I have seen the Max Connections issue before. I think it mostly effects the 7510 and 7520 and tends to happen when you use the escape key on the BlackBerry.

Is that what you are using?

I thought about trying to force the connection closed in the Midlets destroyApp method but never had a chance to try it.

Jon
   
  (#4 (permalink)) Old
consilient_sam Offline
New Member
 
Posts: 3
Join Date: Oct 2005
Location: St. John's
Model: 7100r
Default 10-31-2005, 07:51 AM

No we don't have either of those devices in the office. We are mostly using 7290's, 7100r's, 6210's, 7780's.... (gprs devices).
   
  (#5 (permalink)) Old
ecarmody Offline
Thumbs Must Hurt
 
Posts: 80
Join Date: Apr 2005
Location: Portland, OR., USA
Model: 8100
Carrier: Cingular
Default 11-07-2005, 03:29 PM

Hi consilient_sam,

Are you using a BES? If no, then check your APN settings; that will affect your ability to connect. Also, when doing socket connection, if not using BES, then you need to use "deviceside=true" as a paramter option on the connection. Both of these scenarios will result in symtops as you describe.

Cheers,
Eric
   
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




TaskMaster for BlackBerry


Copyright © 2004-2008 BlackBerryNews.com, BlackBerryFAQ.com, BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of Research In Motion Limited.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.1