小编asc*_*scu的帖子

Android上的Http连接超时无法正常工作

我正在写一个连接到Web服务应用程序,我不希望它等待太久,如果它不能得到一个连接.因此,我设置了httpparams的connectionTimeout.但它似乎没有任何影响.

测试我暂时关闭我的WLAN.该应用程序试图连接相当长的一段时间(超过秒3我想办法更多),然后抛出一个UnknownHostException.

这是我的代码:

try{
    HttpClient httpclient = new DefaultHttpClient();
    HttpParams params = httpclient.getParams();
    HttpConnectionParams.setConnectionTimeout(params, 3000);
    HttpConnectionParams.setSoTimeout(params, 3000);

    httppost = new HttpPost(URL);
    StringEntity se = new StringEntity(envelope,HTTP.UTF_8);
    httppost.setEntity(se);
    //Code stops here until UnknownHostException is thrown.
    BasicHttpResponse httpResponse = (BasicHttpResponse) httpclient.execute(httppost);

    HttpEntity entity = httpResponse.getEntity();
    return entity;

}catch (Exception e){
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

任何人都有我想念的想法吗?

post android timeout http

42
推荐指数
3
解决办法
5万
查看次数

了解Android WebView是否显示缓存页面

我正在制作一个Android应用程序,其中包括在webview中显示网站.据我所知,如果无法建立连接,webview会自动显示页面的缓存版本.

有没有办法找出所显示的页面是否已从服务器或缓存中获取?

甚至可能是缓存页面的年龄.

这是为了能够通知用户他/她是否正在查看旧信息.

android caching webview

7
推荐指数
1
解决办法
6123
查看次数

使用grails获取连接池状态

我有一个用grails构建的web服务连接到MySQL数据库.自从我升级到2.4.3后,我遇到连接池没有释放连接的问题,导致异常:

org.apache.tomcat.jdbc.pool.PoolExhaustedException: [http-bio-8080-exec-216] Timeout: Pool empty. Unable to fetch a connection in 30 seconds, none available[size:50; busy:50; idle:0; lastwait:30000]
Run Code Online (Sandbox Code Playgroud)

这是我的Datasources.groovy

dataSource {
    url = "jdbc:mysql://..."
    username = "xxx"
    password = "xxx"
    pooled = true
    properties {
        maxActive = 50
        maxAge = 10 * 60000
        timeBetweenEvictionRunsMillis = 5000
        minEvictableIdleTimeMillis = 60000
        numTestsPerEvictionRun=3
        testOnBorrow=true
        testWhileIdle=true
        testOnReturn=true
        validationQuery="SELECT 1"
    }
}
dataSource_survey {
    url = "jdbc:mysql://..."
    username = "xxx"
    password = "xxx"

    pooled = true
    properties {
        maxActive = 50
        maxAge = 10 …
Run Code Online (Sandbox Code Playgroud)

grails connection-pooling

3
推荐指数
1
解决办法
3726
查看次数

标签 统计

android ×2

caching ×1

connection-pooling ×1

grails ×1

http ×1

post ×1

timeout ×1

webview ×1