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 Developer
balebaron
Posts: 13
Registered: ‎11-24-2009
My Device: Not Specified

Application hangs waiting for a response after uploading an image

I am working on an application that needs to upload multiple image files to a server. I have followed multiple examples and read a lot of the issues that other people have had with this process. My problem is that the process is consistently inconsistent. I am able to upload the image and my code that handles the image on the server works as expected. The problems is that after uploading, one to a couple of images, flushing the OutputStream or getting the response code causes the app to hangs as if it is waiting for a response from the server. Looking at the MDS console output I can see the request received by MDS, the request sent to the server, the response received by MDS and the response MDS sends to the device. This all happens but the app just sits there. Below is the code that I am using to upload the images. I am open for any suggestions.

 

 

httpConnection = (HttpConnection) Connector.open(url);
httpConnection.setRequestMethod(HttpConnection.POST);
httpConnection.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_LENGTH, Integer.toString(imageBytes.length));
httpOutStream = httpConnection.openOutputStream();
httpOutStream.write(imageBytes);
httpOutStream.flush();
int rc = httpConnection.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
	throw new IOException("HTTP response code: " + rc);
}

 Here is some of the output from MDS:

 

 

HTTP Thread: DefaultJobRunner-2 started>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION =>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Transmission Line Section]:>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = POST /mobile/WebServices/UploadImage?auth=encryption&phoneN
te=1265242435233 HTTP/1.1>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Headers Section]: 3 headers>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = x-rim-conttime:10000>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Host:balebaron-mac>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Content-Length:32623>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Parameters Section]: 8 parameters>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = auth=encryption>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = phoneNumber=8018427547>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = projectCode=test4>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = profileCode=5L>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = imgName=xs_img>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = imgDesc=Zoomed>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = imgBy=Brian LeBaron>
HANDLER = HTTP, EVENT = ReceivedFromDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = imgDate=1265242435233>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION =>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Transmission Line Section]:>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = POST /mobile/WebServices/UploadImage?auth=encryption&phoneNumber=
5242435233 HTTP/1.1>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Headers Section]: 7 headers>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Connection:close>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Via:MDS_4.1.5.26>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Accept:*/*>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = x-rim-original-accept:*/*>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = x-rim-conttime:10000>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Host:balebaron-mac>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Content-Length:32623>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Parameters Section]: 8 parameters>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = auth=encryption>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = phoneNumber=8018427547>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = projectCode=test4>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = profileCode=5L>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = imgName=xs_img>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = imgDesc=Zoomed>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = imgBy=Brian LeBaron>
HANDLER = HTTP, EVENT = SentToServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = imgDate=1265242435233>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION =>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Transmission Line Section]:>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = HTTP/1.1 200 OK>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Headers Section]: 10 headers>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Connection:close>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Expires:Thu, 04 Feb 2010 00:18:02 GMT>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Date:Thu, 04 Feb 2010 00:18:01 GMT>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = X-AspNetMvc-Version:1.0>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Server:Microsoft-IIS/7.0>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Content-Length:38>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = X-Powered-By:ASP.NET>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Cache-Control:private>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = X-AspNet-Version:2.0.50727>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Content-Type:text/html; charset=utf-8>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Parameters Section]: 0 parameters>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Entity Content Section]: 38 bytes>
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = ---------- Content ------------->
HANDLER = HTTP, EVENT = ReceivedFromServer, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION =>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION =>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Transmission Line Section]:>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = HTTP/1.1 200 OK>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Headers Section]: 11 headers>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Connection:close>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Expires:Thu, 04 Feb 2010 00:18:02 GMT>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Date:Thu, 04 Feb 2010 00:18:01 GMT>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = X-AspNetMvc-Version:1.0>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Server:Microsoft-IIS/7.0>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Content-Length:38>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = X-Powered-By:ASP.NET>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = x-rim-etag:"18F118E396C62A76948F7C45E408E4B0E7CC1B72">
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Cache-Control:private>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = X-AspNet-Version:2.0.50727>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = Content-Type:text/html; charset=utf-8>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Parameters Section]: 0 parameters>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = [Entity Content Section]: 38 bytes>
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = ---------- Content ------------->
HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION =>
EVENT = QueueSize, DEVICEPIN = 2100000a, SendingQueueSize = 0>
HTTP Thread: DefaultJobRunner-2 stopping>
EVENT = Sending, TAG = 1906507783, DEVICEPIN = 2100000a, VERSION = 16, CONNECTIONID = 650173457, SEQUENCE = 0, TYPE = DATA, SIZE = 229>
HTTP Thread: DefaultJobRunner-2 stopped>
VENT = Finished JobRunner: DefaultJobRunner-2, available threads in DefaultJobPool = 10, time spent = 344ms>
EVENT = Sending, TAG = 1906507784, DEVICEPIN = 2100000a, VERSION = 16, CONNECTIONID = 650173457, SEQUENCE = 1, TYPE = DISCONNECT-ORDER, SIZE = 0>
VENT = Device connections: AVG latency (msecs)97>
HTTP Thread: ConnectionsInputStreamesReader2-DefaultJobRunner-2 stopping>
HTTP Thread: ConnectionsInputStreamesReader2-DefaultJobRunner-2 stopped>
EVENT = RemovedReceivingQueue, DEVICEPIN:CONNECTIONID = 2100000a:650173457, ReceivingQueueSize = 0>

 

 

To me this line shows that a response is being sent back to the device:

 

 

HANDLER = HTTP, EVENT = SentToDevice, DEVICEPIN = 2100000a, CONNECTIONID = 650173457, HTTPTRANSMISSION = HTTP/1.1 200 OK>

 

 

If I pause the thread in the debugger, it leads back to the httpOutStream.flush() call and is currently in DatagramProtocol(ConnectionBase).receive(Datagram) It just sits there and spins until the connection times out.

 

Any help?

 

 

New Developer
balebaron
Posts: 13
Registered: ‎11-24-2009
My Device: Not Specified

Re: Application hangs waiting for a response after uploading an image

After looking into this further, it appears that my code works as expected on the 5.0 simulator and a 5.0 device. I had hope that it was just a problem with the 4.7 simulator, but this morning I attempted to run the same code on a 4.7 device and it has the same symptoms as the 4.7 simulator described in my initial post.

 

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

Re: Application hangs waiting for a response after uploading an image

Can you confirm that you have compiled the code using OS 4.7 component pack or JDE (or earlier level)?

New Developer
balebaron
Posts: 13
Registered: ‎11-24-2009
My Device: Not Specified

Re: Application hangs waiting for a response after uploading an image

Yes, it has been compiled using the 4.7 component pack.