HttpClient 在本地tomcat中可以发起访问,但是部署到线上环境就无法访问!!!
HttpClient 版本4.3.1
private static HttpClient httpClient;
static {
httpClient = HttpClients.custom().setSSLSocketFactory(MySSLConnectionSocketFactory.getInstance()).build();
}
private static String getLoginResult() throws UnsupportedEncodingException, IOException {
List<NameValuePair> formParams = new ArrayList<NameValuePair>();
formParams.add(new BasicNameValuePair("userName", "testAccount");
formParams.add(new BasicNameValuePair("password","password");
HttpEntity entity = new UrlEncodedFormEntity(formParams, "UTF-8");
return HttpUtil.requestPost(LOGIN_URL, entity);
}
public static String requestPost(String url, HttpEntity entity) throws IOException {
HttpPost httpPost = new HttpPost(url);httpPost.setEntity(entity);
HttpResponse httpResponse = httpClient.execute(httpPost);
return EntityUtils.toString(httpResponse.getEntity(), ContentType.get(entity).getCharset());
}
HttpClient 做了饶过证书的处理。
在调用getLoginResult()方法时,在本地tomcat上跑是可以发起请求并能返回正确结果,但是发布到linux服务器上就会卡在 execute 这里。
这个是服务器屏蔽了吗?如何解决啊?求大神帮忙。。。。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
顶啊...快来人..