简体   繁体   English

如何使连接保持活动状态以访问URL

[英]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 我有一个网址,例如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. 此URL有连接超时,这意味着如果我停止访问此URL 10秒钟,则该URL将无法再次访问。 Server generates new random number for every new URL to access the contains on the server. 服务器为每个新URL生成一个新的随机数,以访问服务器上的包含内容。

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". 一段时间后,应用程序会在一段时间(超过超时时间)后请求此网址,原因是我的应用程序收到的响应为“ 403 Forbidden”。

So how can i keep the connection to this url ali 那么我如何才能保持与该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, .. 保持开放的连接是一个非常糟糕的主意,除了消耗用户的电池外,还可能由于其他原因而断开连接,例如信号低,在3g和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 如果您需要异步将数据发送到设备,请使用某种推送通知机制,例如http://developer.android.com/google/gcm/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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