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 Contributor
braden1987
Posts: 2
Registered: ‎03-19-2011
My Device: Curve, Bold, Torch (access to, for dev testing)
My Carrier: Various
Accepted Solution

Socket connection working in simulator with MDS but not on curve

[ Edited ]

Hello,

 

Working on an app that uses socket connections.

 

soc = (SocketConnectionEnhanced)Connector.open("socket://" + address.ip_number + ":" + address.port_number + ";deviceside=true");

 

Go on to use a DataInputStream and DataOutputStream to communicate.

 

The server is working, can transmit fine with simulator as well as another curve (not same model) . (There is a slim chance that deviceside=true wasn't passed as a parameter when we tested on the other curve, so that would make it go through BES ?? It was probably still there though).

 

Imho, this means the only places the issue could exist are a) how the code is applied on the phone client or b) the phones or their settings (have 4 curve 8530s on the same CDMA network).

 

- These phones were just activated in the past few days, is there any chance something is missing from the service book to allow for socket connections? (I doubt this as I downloaded ping messenger which I assume uses sockets.. and all is fine).

 

Any application permission I need to set?

 

Out of ideas !! Please let your mind flow. Thank You!

 

 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Socket connection working in simulator with MDS but not on curve

Welcome to the forums.

 

I presume you have reviewed this:

http://supportforums.blackberry.com/t5/Java-Development/Different-ways-to-make-an-HTTP-or-socket-con...

 

and so are familiar with the various connection suffixes you can add and the effect they can have. 

 

If you have BES connected devices, I recommend that you use BES connection (";deviceside=false").  If they are BES devices and the BlackBerry Browser works, then you should be able to talk using that connection suffix.. 

 

It is unlikely that there are Service Records missing - I won't look there first.

 

With regard to permissions, the phone will typically produce a prompt asking for this the first time your application attempts to connect.  If this is denied, you application will get an Security Exception.

 

Review the above and hopefully it will help.  If not, then can you debug the failing connection and tell us what Exception you are seeing from the BlackBerry side.

 

One final think, if you are using DataInputStream, be careful about using readFully - I think there are some issues with it.  I would recommend that you just use InputStream and OutputStream if you can. 

Please use plain text.
New Contributor
braden1987
Posts: 2
Registered: ‎03-19-2011
My Device: Curve, Bold, Torch (access to, for dev testing)
My Carrier: Various

Re: Socket connection working in simulator with MDS but not on curve

[ Edited ]

For anyone who might find this thread after encountering the same problem:

 

The issue was with the DataInputStream ... available() was ALWAYS returning zero, even though there were more bytes to read. This was only on our 4  Curve 8530s testing phones. Tried it on another Curve and a Bold and they didn't have this issue.

 

Stopped using  available() and tried a read for much larger than any of our packets will be (5000 bytes).

Have some test phones with 5.0.0.337 they wouldn't work with this.

After upgrading to 5.0.0.1000 they all work perfectly.

 

I read somewhere that the available() issue has to do with J2SE -> J2ME problems, something about a wrapper. This issue exists (or did exist) with TSL/SSL apparently (sorry I can't find the thread I'm getting this info from, if anyone really wants to see it reply and I'll grab the link from the history of my laptops browser).

 

Hope this helps someone!!

 

B

Please use plain text.