ews-java-api java.net.ConnectException:https的连接超时 [英] ews-java-api java.net.ConnectException: Connection timed out for https
问题描述
我正在使用 https://github.com/提供的ews-java-apiOfficeDev/ews-java-api/.虽然代码可以在本地正常运行,但是在我们的服务器上运行时,出现以下异常.来自服务器的URL的Curl命令运行正常.因此,网络团队排除了防火墙问题.
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.
下面是完整的堆栈跟踪
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密钥库中.但是没有任何帮助.有人可以帮助确定问题的原因吗?
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?
部分代码在下面
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本身的错误.我注意到在服务上设置的Web代理实际上并没有在HttpClientWebRequest中设置.NTLM或任何东西都没有问题.因此,关闭它.
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.
这篇关于ews-java-api java.net.ConnectException:https的连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!