BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-17-2009, 12:20 PM   #1 (permalink)
New Member
 
Join Date: Apr 2009
Model: 8320
OS: 4.5.1
PIN: N/A
Carrier: ATT
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Sending File Application Freezes then continues but no file sent

Please Login to Remove!

I have an application utilizing kxmlrpc and regular http connections. In the JDE 4.2 through 4.5 the application is listening for a FileJournal Event when the camera app it invokes creates a new image. In the JDE 4.6 and above the application is utilizing the embedded VideoControl.

The issue comes when trying to send the file too a webserver either utilizing HttpConnection or the kxmlrpc library (note the kxmlrpc works in sending everything else up to the point of trying to send the file) However the application just hangs for the 120 second timeout and never actually sends the file too the server, in the server logs no HTTP POST is received for either HttpConnection or XML-RPC.

Below is the code being utilized in both cases. Would you have any thoughts regarding this?

This is the kxmlrpc way and we retrieve the file contents into the base64Encoded byte[] and it is based on viewing in the debugger converted to base64 and the appropriate <base64> tags are put into the xmlrpc request.
PHP Code:

    
public static String createNewFile(String titleString filePath) {
       
String rCode null;
       
bytexxx91;xxx93; base64Encoded Util.getFileContents("file://"filePath);
        
// Retrieve the User object of the user who is currently logged in via the Mobile Client
        
Hashtable deviceUser MobileApp.getDeviceUser();
        
String sDeviceUserName = (String) deviceUser.get("name");
        
// Retrieve the user id from the user object hashtable
        
Integer deviceUserID;
        
String sDeviceUserID = (String) deviceUser.get("uid");        
        if (
sDeviceUserID == null) {
            
deviceUserID = new Integer(0);
        } else {
            
deviceUserID = new Integer(Integer.parseInt(sDeviceUserID));
        }        
        try {
            
xmlrpc = new XmlRpcClient(MobileApp.getUrl());
            
Hashtable nodeValues = new Hashtable();
            
nodeValues.put("title"title);
            
nodeValues.put("uid"deviceUserID);
            
nodeValues.put("name"sDeviceUserName);
            
nodeValues.put("type""file");
            
nodeValues.put("status", new Integer(1));           
            
Vector params = new Vector();
            
params.addElement(MobileApp.getSessID());
            
params.addElement(nodeValues);
            
params.addElement(base64Encoded);
            
rCode = (String) xmlrpc.execute("file.save"params); 
            
xmlrpc null;
        } catch (
Exception e) {
            
xmlrpc null;
            final 
String msg e.toString();
            
UiApplication.getApplication().invokeLater(new Runnable() {
                public 
void run() {
                    
Dialog.alert("File Error: " msg);
                }
            });
            
rCode null;
        }
        return 
rCode;        
    } 
The below code is the same code for the HttpConnection

PHP Code:
public static int createNewFile(String titleString filePath) {
        
int httpRespCode 0;
        
String CrLf "\r\n";
        
bytexxx91;xxx93; cameraImage Util.getFileContents("file://"filePath);
        try {         
            
MultipartPostData post = new MultipartPostData(cameraImage);
            
HttpConnection conn = (HttpConnection)Connector.open(mobileUrlConnector.READ_WRITE);
            
conn.setRequestMethod(HttpConnection.POST);
            
conn.setRequestProperty("User-Agent""Blackberry");
            
conn.setRequestProperty("Content-Type""multipart/form-data; boundary=---------------------------4664151417711");
            
//conn.setRequestProperty("Content-Type", post.getContentType());    
            
String message0 "";
            
message0 += "-----------------------------4664151417711" CrLf;
            
message0 += "Content-Disposition: form-data; name=\"title\"";
            
// Value will be sent in this portion
            
            
String message1 "";
            
message1 += "-----------------------------4664151417711" CrLf;
            
message1 += "Content-Disposition: form-data; name=\"cameraImage\"; filename=\"camera.jpg\"" CrLf;
            
message1 += "Content-Type: image/jpeg" CrLf;
            
message1 += CrLf;

            
// the image is sent between the messages in the multipart message.
            
String footer CrLf "-----------------------------4664151417711--" CrLf;              
            
OutputStream os conn.openOutputStream();
            
os.write(message1.getBytes());
            
// Sending the image to the server
            
int index 0;
            
int size 1024;
            do {
                if ((
index size) > cameraImage.length) {
                    
size cameraImage.length index;
                }
                
os.write(cameraImageindexsize);
                
index += size;
            } while (
index cameraImage.length);
            
os.write(footer.getBytes());
            
os.flush();
            
httpRespCode conn.getResponseCode();
        } catch (
IOException ioEx) {
            final 
String msg ioEx.toString();
            
UiApplication.getApplication().invokeLater(new Runnable() {
                public 
void run() {
                    
Dialog.alert("IO Exception: " msg);
                }
            });
        } catch (
Exception e) {
            final 
String msg e.toString();
            
UiApplication.getApplication().invokeLater(new Runnable() {
                public 
void run() {
                    
Dialog.alert("Exception: " msg);
                }
            });
        }
        return 
httpRespCode;
    } 
It does the same in JDE 4.2 all the way to JDE4.7 and i have also added the app too a Blackberry curve 8830 running 4.5 and it does the same thing hangs then comes back after the timeout.
Offline  
Old 10-17-2009, 03:51 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

What connection parameter(s) are you appending to your URL, if any?

What carrrier are you on?
Offline  
Old 10-17-2009, 03:59 PM   #3 (permalink)
New Member
 
Join Date: Apr 2009
Model: 8320
OS: 4.5.1
PIN: N/A
Carrier: ATT
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Connection parameters "deviceside=false" after the url for the HttpConnection. For the KXMLRPC i do not believe any are being sent.

Network on the 4.5 is AT&T and the simulator using the 4.1.2 version of the MDS in order to provide the connection.

The HttpConnection code worked on a previous app and still does but for some reason it does not work in this app the app is only having the issue when sending the image. All other connections HTTP POST via KXMLRPC work fine passing the data.

I am wondering if there might be an issue with memory or something but i am just clutching at straws with that since file free is 128322129 so i do not believe that is the issue since it is over 12 Mb.

Phone is brand new no other apps on it, and the simulator i am running clean.bat on it and only loading the kxmlrpc library and the application.
Offline  
Old 10-17-2009, 08:20 PM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

I'm confused; is this not working on the simulator, or the device, or both?

On the device, ";deviceside=false" is not going to get you anywhere on AT&T, unless the unit is on a BES network. You'll need to specify the APN or WAP gateway info.

For AT&T, the APN shoud be set to "proxy"

Your parameter should be ";deviceside=true;apn=proxy"

See the attached article for more info on specifying the APN.

http://www.blackberry.com/knowledgec...65025&vernum=0
Offline  
Old 10-17-2009, 08:22 PM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

One other comment - I have never successfully gotten the 4.1.2 MDS app to work with 4.5 - I had to install 4.1.4.

Not sure this is your issue, just thought I'd mention it.
Offline  
Old 10-17-2009, 10:37 PM   #6 (permalink)
New Member
 
Join Date: Apr 2009
Model: 8320
OS: 4.5.1
PIN: N/A
Carrier: ATT
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

It does not work on both the simulator and the device. I will try the new MDS and also try the proxy portion to determine if that is the issue.

My main concern was to get it working in the simulator first then try the device again since i thought the issue might be AT&T. Will try your above suggestions and let you know the results.
Thank you for the reply
Offline  
Old 10-18-2009, 09:43 AM   #7 (permalink)
New Member
 
Join Date: Apr 2009
Model: 8320
OS: 4.5.1
PIN: N/A
Carrier: ATT
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
One other comment - I have never successfully gotten the 4.1.2 MDS app to work with 4.5 - I had to install 4.1.4.

Not sure this is your issue, just thought I'd mention it.
Yep this was the issue for the simulator i changed the MDS and it now works correctly through kxmlrpc and is sending the file.

Will need to re-check the Phone but wont have access till tomorrow to verify that with the apn=true and deviceside=true parameters.

Thank you for the assistance in this hopefully this should now make the app work correctly.
Offline  
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





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.