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



我使用的是由https://github.com/OfficeDev/ews-java-api/.虽然代码在我的本地运行得很好,但当在我们的服务器上运行时,我会得到以下异常。来自服务器的URL的Curl命令非常有效。因此网络团队排除了防火墙问题。

下面是全栈跟踪

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"));

这是ews-javaapi本身的一个错误。我注意到,在HttpClientWebRequest中实际上并没有设置服务上的set web代理。NTLM或任何东西都没有问题。就此结束。

最新更新