views:

271

answers:

6

I have made an App that can connect to a program that I am running on a server, but it only seems to work with WiFi. When I try to use 3G it doesn't make the connection. Is there something special that I have to turn on or set in order to use 3G?

+1  A: 

At the application level you (normally) don't have to worry about what data connection is available to the phone.

Have you looked into problems such as when you use WiFi you web server is accessible since you are hitting it from within your network. Whereas, it may not be accessible at all from the public internet which is how the 3G connection will be trying to connect to the server.

What error / exception do you get on 3G?

Prashast
A: 

There shouldn't be anything additional between Wifi, and 3G. All I've included in my Manifest Permissions is android.permission.INTERNET, and that works fine with either Wifi or 3G, so assuming INTERNET is required for Wifi as well (which I'm not entirely sure about, since I haven't tried JUST Wifi) and you've already included it, I don't know of anything else.

If by some chance Wifi does NOT require INTERNET, and it happens to work without it, the Manifest should include a line like:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

which should grant internet (and 3G) access for your phone. Sorry if that doesn't answer the question, but I can't think of any other reason 3G would be an issue when Wifi works fine. Additionally, make sure you can access the network from another outside location--as said before me, it may be a matter of security preventing outside access somehow. (Not sure what you're using 3G to connect to)

Matt D
A: 

The exception that is getting thrown when the socket is made is an IOException, and the timeout (4000) gets reached. When the phone is in Wi-Fi it works fine but when it uses 3G the socket cannot connect to the host/port.

RJAAAY
A: 

You'll have to check with your phone company (and good luck in finding someone who can answer!!) that the 3G network doesn't block ports that you're expecting to be open (and are when in WiFi mode). Some telcos block almost everything you'd expect (and your app stack assumes to be available) to be standard on 3G nets (ping, telnet, RDP etc., etc.).

Keith Fisher
A: 

The problem was the port I was using. I was using 4444, but it turns out that many networks block that port. Port 1024 seems to work for most.

gamernb