BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 09-28-2009, 02:29 PM   #1 (permalink)
New Member
 
Join Date: Sep 2009
Model: 8330
PIN: N/A
Carrier: TELUS
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Help: Direct TCP/IP connection cause device reset

Please Login to Remove!

I had an application which send the data to our server through "Direct TCP" connections. I had install the application on some Curves (8310, 8330, and 8350i - iDen), and most of them works.

However, I had encountered some issues with the phones from Roger's.

Whenever I try to "Write" through the socket connection, the device will reset on me (just like pull the battery - soft reset).

Nevertheless, http does work in my application (I use it to exchange information once a long while).


Thank you very much for your valuable time and great assistance...

---------------------------------------------

Carrier: Rogers (EDGE)
Model: 8310 Curve
OS: 4.5.0.81

The following is my code... Please advice

---------------------------------------------

private OutputStreamWriter os;
private StreamConnection sc;
private String message;

public boolean send(String msg) {
this.message = msg;

if (this.message == null || this.message.equals("")) {
return false;
}

try {
sc = (StreamConnection) Connector
.open("socket://myServerIP:" + 8772 + ";deviceside=true;");

os = new OutputStreamWriter(sc.openOutputStream());

this.message = this.message + " EOF";

// <------ THIS IS WHERE IT CAUSE THE RESET -------->
os.write(this.message, 0, this.message.length());
// <------ END OF THE PROBLEM ----->

if (os != null) {
os.close();
}

if (sc != null) {
sc.close();
}
} catch (IOException ioe) {
ioe.printStackTrace();
}

// Completed client handling, return handler to pool and
// mark for wait
this.message = null;

return true;
}
Offline  
Old 09-28-2009, 02:47 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

Which JDE level did you use to compile the code?
Offline  
Old 09-28-2009, 03:07 PM   #3 (permalink)
New Member
 
Join Date: Sep 2009
Model: 8330
PIN: N/A
Carrier: TELUS
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much for your response..

I did not set it, where can I set it?

I guess I use the default level (since I didn't define it)


Best regard..
Offline  
Old 09-28-2009, 05:44 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

Are you using the JDE or Eclipse? Either way, you don't "set" it, you download and install the tool for the version you are trying to target.

Here is why I ask: this sounds like an incompatibility between the JDE level the code was compiled for, and the OS level on the device.

So, if you compiled on JDE 4.7, and loaded this code on a 4.2 device, you might get a reset.
Offline  
Old 09-28-2009, 07:30 PM   #5 (permalink)
New Member
 
Join Date: Sep 2009
Model: 8330
PIN: N/A
Carrier: TELUS
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much for the advise...

However, I had tried to use the older version of JDE; still no lock with the app, it is still resetting.. sigh~~

My friend had advise me to use SOAP; which I do not understand how can it help me.

If http works, is it possible I can use http for everything? Only concern I have is that I need to access the database, and I make a connection every 5~10 seconds. As a result, we need to connect/disconnect to my database every 5~10 second. This might overload my DB Server. Later on, we might have more than 50 phones. If each phone does this (5~10 second thing), I will crash my DB server for sure. (Exclude the bad connection, assume 4/5 works, it still generate 40 connection in every 5~10 seconds repeatly).


I had phoned Roger's Tech support; the representive was unable to help me..


Any kind of suggestion and advice is greatly appricate....

Best regard...
Offline  
Old 09-28-2009, 08:18 PM   #6 (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

We have an apps running with 50K users hitting the database.

HTTP works, but you'll need a little server-side middleware to do the database queries and return the result.

SOAP is OK, but you can also "roll your own" web service and just return an XML document with the payload.

Anyway, there are many ways to accomplish this. You'll need to do a little research to find what works for you specific situation.

Last edited by Dougsg38p : 09-28-2009 at 08:21 PM.
Offline  
Old 09-28-2009, 08:29 PM   #7 (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

This line of code:

os.write(this.message, 0, this.message.length())

Doesn't look right to me.

Shouldn't it be:

os.write(this.message.getBytes(),0,this.message.le ngth())

Take a look at the docs for OutputStream. The first arg should be a byte array, you are passing the reference of a string.
Offline  
Old 09-28-2009, 09:13 PM   #8 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
This line of code:

os.write(this.message, 0, this.message.length())

Doesn't look right to me.

Shouldn't it be:

os.write(this.message.getBytes(),0,this.message.le ngth())

Take a look at the docs for OutputStream. The first arg should be a byte array, you are passing the reference of a string.
Looked at that Doug, the OP's os is an OutputStreamWriter, his use of the method is correct.

I'm wondering if this is a threading issue, ie) is the writing on the application event thread?
__________________
My other Blackberry is a PlayBook.
Offline  
Old 09-29-2009, 12:21 PM   #9 (permalink)
New Member
 
Join Date: Sep 2009
Model: 8330
PIN: N/A
Carrier: TELUS
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dougsg38p:
Thank you for your reply, I will try to use http and see how it will turn out. I hope the result is okay (or at least, acceptable).


hrbuckley:
Yes, I am running the "writing" operation in a thread. Will it cause the reset or crash? I did add the try/catch, shouldn't it catch the exception and prevent the system crash?


Once again, thank you very much for your valuable time and great assistance... really appriciate it....

Best regard...
Offline  
Old 09-29-2009, 12:23 PM   #10 (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

Do you have multiple threads writing to the socket?

What is the size of the data when the device reset occurs?

Does the reset happen immediately, or does some data get transferred first?
Offline  
Old 09-29-2009, 01:01 PM   #11 (permalink)
New Member
 
Join Date: Sep 2009
Model: 8330
PIN: N/A
Carrier: TELUS
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I only run one socket at a time...

The data size is normally between 90 ~ 120 bytes; and it will never get more than 200 bytes

The reset happen immediately when the "write" action launch. None of the data had being send. If I comment out that line, everything works (it will just simply open and close the connection without sending anything).



Thank you ~^^~
Offline  
Old 09-29-2009, 02:34 PM   #12 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Quote:
Originally Posted by WhereRU View Post
Dougsg38p:
Thank you for your reply, I will try to use http and see how it will turn out. I hope the result is okay (or at least, acceptable).


hrbuckley:
Yes, I am running the "writing" operation in a thread. Will it cause the reset or crash? I did add the try/catch, shouldn't it catch the exception and prevent the system crash?


Once again, thank you very much for your valuable time and great assistance... really appriciate it....

Best regard...
No, running socket (including http(s)) writing, and especially reading in a separate thread is the thing to do. Though the worst that should happen is the GUI hangs while the stream is blocking, usually on read, but it can happen on writes. If the JVM acctually gets to throw an exception, even if you don't catch it, the worst that should happen is your application exits and an Uncaught Exception dialog pops up.

This is very odd.

4.5.0.81 is an old OS even for Rogers, 4.5.0.108 is available. Is it possible for you to upgrade the OS and try the code again?

Strike that, my bad bundle 108 is build 81. Damn!
__________________
My other Blackberry is a PlayBook.

Last edited by hrbuckley : 09-29-2009 at 02:39 PM. Reason: Info on OS.
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.