简体   繁体   中英

How to keep the connection alive for accessing URL

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM