ews-java-api java.net.ConnectException:https的连接超时

时间:2015-02-26 10:57:32

标签: java exchangewebservices

我正在使用https://github.com/OfficeDev/ews-java-api/提供的ews-java-api。虽然代码完全可以从我的本地运行,但在我们的服务器上运行时,我得到以下异常。来自服务器的URL的卷曲命令完美地运行。因此网络团队排除了防火墙问题。

以下是完整的堆栈跟踪

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)

我甚至尝试过设置代理,代码是非常基本的文档中给出的示例。我们正在连接到https URL,正如我从文档中看到的那样,所需的代码已经内置在api中。我还尝试将证书添加到java密钥库。但没有任何帮助。有人可以帮助确定问题的原因吗?

部分代码在

之下
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 个答案:

答案 0 :(得分:0)

这是ews-java-api本身的一个错误。我注意到服务上的set web代理实际上并没有在HttpClientWebRequest中设置。 NTLM没有任何问题。因此关闭此。