1

I have one URL something like http:xx.xx.xx.xx:80/random_number/xyz.html

There is connection timeout for this url, means if i stop accessing this URL for 10 seconds then this URL is not accessible again. Server generates new random number for every new URL to access the contains on the server.

Some time this happens that app requests this url after some time (more than the timeout time) and because of that my application receive response as "403 Forbidden".

So how can i keep the connection to this url ali

User7723337
  • 11,857
  • 27
  • 101
  • 182
  • 1
    You can't without draining the battery like hell. – flx Dec 05 '13 at 07:36
  • i think will help you to implement mqtt service.. this will keep alive your connection to server. this will not drain battery and is very usefull when you want to send notifications. I suggest to use paho library. [link](http://stackoverflow.com/questions/10065624/how-to-send-ping-using-ecipse-paho-mqtt-client) – ovluca Dec 05 '13 at 08:08

1 Answers1

0

Its a pretty bad idea to keep an open connection, in addition to draining the user's battery, the connection can be dropped because of other things, like low signal, switching between 3g and wifi, ..

If you need to asynchronously send data to the device, use some sort of push notifications mechanism, such as http://developer.android.com/google/gcm/index.html

Gal Ben-Haim
  • 17,433
  • 22
  • 78
  • 131