本地和线上httppost请求问题?

public static String doJsonPost(String url, JSONObject params)
throws ClientProtocolException, IOException {
HttpClient httpclient = HttpClients.createDefault();
//毫秒
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(5000000).setConnectionRequestTimeout(1000000)
.setSocketTimeout(5000000).build();
// HttpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
HttpPost httpPost = new HttpPost(url);
httpPost.setConfig(requestConfig);

    httpPost.setHeader("User-Agent",
            "Mozilla/5.0 (Windows NT 6.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2");

    StringEntity entity = new StringEntity(params.toString(), "utf-8");// 解决中文乱码问题
    entity.setContentEncoding("UTF-8");
    entity.setContentType("application/json");
    httpPost.setEntity(entity);
    return httpclient.execute(httpPost, new MyResponseHandler<Object>())
            .toString();
}

这是我的工具类 但是在本地的话就可以吧数据传到第三方 我部署到服务器怎么就网络超时啊

超时大部分是网络的问题
比如:对方有IP白名单
你可以在服务器上 访问下对方 的服务器地址,看是否通畅。

在服务器依次用
curl ip
curl 域名
试下通不通!
如果ip可以,域名不行,说明服务器域名解析有问题,2者都不通说明服务无外网访问权限。
依据结果,做下一步处理!

Linux服务器的话
可能端口没有打开
被防火墙阻止了