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