Android Question TCP Socket over cellular

Rusty

Well-Known Member
Licensed User
I have been using a cellular device to communicate with a static IP computer (PC).
1. When I use WiFi, it works great, sockets connect, astreams works
2. When I use cellular, it connects and communicates only very seldom.

Is there a difference that I should know about to be able to do TCP/IP socket communications via Cellular vs. WiFi?
Thanks,
Rusty
 

Rusty

Well-Known Member
Licensed User
We do connect (sometimes), then disconnect, then connect etc.
The PC on the other end is inside a firewalled community and port 80 is specifically restricted...
If we connect at all, wouldn't that imply that the port number is not the issue?
Thanks Erel,
Rusty
 
Upvote 0

Beja

Expert
Licensed User
It's a game (I think), played by the carriers to save bandwidth, even though they tell you it's unlimited., specially when used to stream media. Check: clear the cache and
try again, but use it for lite communication like sending some commands and retrieve short texts.
 
Upvote 0

coslad

Well-Known Member
Licensed User
The server is a vb6 apps listening on a specific port, when i try to send any byte from an android app, the connection is established and close immediatly, if the mobile phone is connected whit an adsl connection everything works fine.
 
Upvote 0

Straker

Active Member
Licensed User
Probably is an issue with your provider.
I'm building an application with a server (VB6 / VBNET) running on a PC (no static IP, therefore it pass through a free no-ip dynamic dsn service, with router port-forwarding) and the client is the phone. It works fine both with wifi (of course) and with mobile data.
The port is not 80 (is just a port) so I can confirm that the port is not a problem.

Can you extract a piece of your source so I can have a look?
 
Upvote 0

coslad

Well-Known Member
Licensed User
English:
It is a simple tcp socket instance.
When the server accept the request from mobile device the connection drops.

Italian:

È una semplice connessione tcp.
Non appena il server accetta la richiesta, viene generato l evento di connessione effettuata ( nel dispositivo mobile) , dopodiché il server inizia ad inviare piccole stringe di pochi byte, questi dati non arrivano mai al dispositivo mobile, dopo qualche secondo il dispositivo non ricevendo nessun dato interpreta la situazione come una caduta della connessione, quindi effettua nuovamente la richiesta, questa viene accettata e tutto ricomincia.
 
Upvote 0

Straker

Active Member
Licensed User
(why don't we switch to the Italian Forum? Open a topic there, if you want)

Your app should work even with cellular connection (if not there will be a lot of games and apps which wouldn't work).
Are you sure the connection drops? Did you get a asyncstream_error event fired? Or simply there is no answer...
Did you try to send a request from the mobile to the server? Maybe it's a simple timeout problem...

If you want we can make some test:
  1. give me IP, port. I'll try with my phone.
  2. give me the port, and I'll setup a listening VB server (I will give you the address) so you can try to contact my server
 
Upvote 0

coslad

Well-Known Member
Licensed User
Hi Straker

i prefer to remain in the international forum to have (and give ) maximum support .

In attach you can find a simple demo project .
I have set up a listening server , i tried under H3G network and after the connection there isn't Exchange of byte , otherwise under wifi i receive data from server.

After the connection , the server send every 2 second the actual date and time , and wait for a keepAlive message from mobile device, after 6 seconds without this keep Alive message , the server close the connection and restart to listening .

The Mobile App after the connection, shows on a label the arrived message and send every 1 second a keepAlive message .
If the mobile App doesn't receive any message from server for 6 seconds , closes the connection and retry to connect
 

Attachments

  • TestTcpIp.apk
    131.7 KB · Views: 212
  • TestTcpIp.zip
    291.6 KB · Views: 393
Upvote 0

Straker

Active Member
Licensed User
I downloaded your project and made a couple of tests. Everything works fine, both with Wifi and mobile data. My provider is TIM.
Probably the H3G provider is cutting down connections made through some ports... (try to call H3G and ask, and post here their answer).
I assume the APN parameters in your phone are correct (the should be automatically set by your provider) but you'd better chek'em anyway...
 
Upvote 0
Top