ews-java-api java.net.ConnectException: Connection timed out for https

被刻印的时光 ゝ 提交于 2019-12-13 06:08:07

问题


I am using the ews-java-api provided by https://github.com/OfficeDev/ews-java-api/. While the code works perfectly from my local, when running on our server I get the below exception. Curl command for the URL from server works perfectly. So network teams rule out firewall issues.

Below is the full stack trace

microsoft.exchange.webservices.data.ServiceRequestException: The request failed. The request failed. Connect to mail.microsoft.com:443 [mail.microsoft.com/131.107.125.5] failed: Connection timed out
    at microsoft.exchange.webservices.data.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:70)
    at microsoft.exchange.webservices.data.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:148)
    at microsoft.exchange.webservices.data.ExchangeService.findItems(ExchangeService.java:819)
    at microsoft.exchange.webservices.data.ExchangeService.findItems(ExchangeService.java:862)
    at microsoft.exchange.webservices.data.ExchangeService.findItems(ExchangeService.java:922)
    at App.main(App.java:74)
Caused by: microsoft.exchange.webservices.data.ServiceRequestException: The request failed. Connect to mail.microsoft.com:443 [mail.microsoft.com/131.107.125.5] failed: Connection timed out
    at microsoft.exchange.webservices.data.ServiceRequestBase.getEwsHttpWebResponse(ServiceRequestBase.java:709)
    at microsoft.exchange.webservices.data.ServiceRequestBase.validateAndEmitRequest(ServiceRequestBase.java:639)
    at microsoft.exchange.webservices.data.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:58)
    ... 5 more
Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to mail.microsoft.com:443 [mail.microsoft.com/131.107.125.5] failed: Connection timed out
    at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:138)
    at org.apache.http.impl.conn.BasicHttpClientConnectionManager.connect(BasicHttpClientConnectionManager.java:318)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at microsoft.exchange.webservices.data.HttpClientWebRequest.executeRequest(HttpClientWebRequest.java:279)
    at microsoft.exchange.webservices.data.ServiceRequestBase.getEwsHttpWebResponse(ServiceRequestBase.java:700)
    ... 7 more
Caused by: java.net.ConnectException: Connection timed out
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:239)
    at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:123)

I have even tried setting the proxy, the code is very basic from the examples given in the documentation. We are connecting to https URL, and as I can see from the documentation, the needed code is already built in in the api. I also tried adding the certificate to the java keystore. But nothing helped. Could someone help identify the cause of the problem?

Part of code is below

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
ExchangeCredentials credentials = new WebCredentials("xxxx", "xxxx","xxxx");
service.setCredentials(credentials);
service.setWebProxy(new WebProxy("proxyhost", proxyport));
service.setUrl(new URI("our exchange url"));

回答1:


This is a bug in the ews-java-api itself. I noticed that the set web proxy on the service isnt actually getting set in the HttpClientWebRequest. There is no issue with NTLM or anything. Hence closing this.



来源:https://stackoverflow.com/questions/28740579/ews-java-api-java-net-connectexception-connection-timed-out-for-https

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!