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
Posts: 4
Registered: ‎12-15-2011
My Device: Curve 9300
My Carrier: Vodafone
Accepted Solution

Problem with SocketConnection over 3G

Hi all,

 

I am stuck with an issue related to socket connections.

 

On WIFI  I am opening a socket connection with the following line:

 

SocketConnection connection = (SocketConnection) Connector.open("socket://212.107.31.2:2299;deviceside=true;interface=wifi;");

 

As expected the line returns an object of type net.rim.device.cldc.io.tcpsocket.TcpClientConnection on which I can open InputStream and OutputStream without problems.

 

With WIFI disabled I use the following line to retrieve a socket connection over 3G:

 

SocketConnection connection = (SocketConnection) Connector.open("socket://212.107.31.2:2299;deviceside=true;");

This is where it gets weird as now an object of type net.rim.device.cldc.io.devicehttp.ClientProtocol is returned instead of the expected TcpClientConnection. Opening an InputStream on the ClientProtocol results in a EOFException, the stacktrace:

 

[0.0] EOFException
[0.0] No detail message
[0.0] net_rim_os-3(4BE21A1D)
[0.0]  Utilities
[0.0]  receiveLine
[0.0]  0xBAEC
[0.0] net_rim_os-3(4BE21A1D)
[0.0]  StatusLine
[0.0]  readFromStream
[0.0]  0xA480
[0.0] net_rim_os-2(4BE21A1D)
[0.0]  ClientProtocol
[0.0]  readResponse
[0.0]  0x16DE
[0.0] net_rim_os-3(4BE21A1D)
[0.0]  HttpProtocolBase
[0.0]  transitionToState
[0.0]  0x4120
[0.0] net_rim_os-3(4BE21A1D)
[0.0]  HttpProtocolBase
[0.0]  openInputStream
[0.0]  0x44B4
[0.0] net_rim_os-3(4BE21A1D)
[0.0]  HttpProtocolBase
[0.0]  openDataInputStream
[0.0]  0x44F0
[0.0] socket_test(4A71D639)
[0.0]  SocketThread
[0.0]  <private>
[0.0]  0x65DE
[0.0] socket_test(4A71D639)
[0.0]  SocketThread
[0.0]  run
[0.0]  0x46FE

 

BTW in case you are wondering I have a full data plan including direct TCP and I can confirm this when I use the sim card in my Android phone.

 

 What am I doing wrong? Any help is appreciated!!!

 

Thanks,

Emma

 

Details: Plattform 6.6.0.212, App Version 6.0.0.570, Device Curve 9300, Carrier Vodafone

 

 

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem with SocketConnection over 3G

I would remove the trailing semicolon from here:

deviceside=true;");

and do the same for WiFi.

 

If you are using deviceside=true, then you need to have set up APN parameters for your carrier in the TCP Options on your device. 

 

I would also be a little cautious with the Port.  I have not be able to connect over anything but standard ports (80 and 443) when using socket connections over the carrier supplied TCP network.  Try what you are doing with a Server listening on port 80 and see if that works.  Then move it it to 2299. 

New Contributor
Posts: 4
Registered: ‎12-15-2011
My Device: Curve 9300
My Carrier: Vodafone

Re: Problem with SocketConnection over 3G

Thank you Peter for putting me on the right track. It was indeed a port issue. A call to the provider confirmed that my data plan is in fact unlimited in terms data volume not so, however, in terms of ports and services. In other words i am stuck with 80/443 unless i extend my data plan.

 

Thanks again Peter, you made my day!!!

 

Emma