Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/131.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ews java api java.net.ConnectException:https的连接超时_Java_Exchangewebservices - Fatal编程技术网

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

ews java api java.net.ConnectException:https的连接超时,java,exchangewebservices,Java,Exchangewebservices,我正在使用由提供的ews java api。虽然代码在我的本地服务器上运行得很好,但在我们的服务器上运行时,我会遇到以下异常。用于服务器URL的Curl命令工作正常。所以网络团队排除了防火墙问题 下面是完整的堆栈跟踪 microsoft.exchange.webservices.data.ServiceRequestException: The request failed. The request failed. Connect to mail.microsoft.com:443 [mail.

我正在使用由提供的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 java api本身的一个bug。我注意到服务上的set web代理实际上没有在HttpClientWebRequest中设置。NTLM或任何东西都没有问题。因此,我结束了这篇文章。

在进一步的分析中,我注意到早期版本的ews java api可以工作,但是这个版本失败了,我注意到的原因是NTLM身份验证。这也不起作用!!!你用的是哪个版本@Sivaw如果我们不使用代理怎么办?那么它应该可以正常工作了?在我的情况下,我没有代理仍然有同样的问题