2017-07-25 73 views
1

正嘗試通過Java使用Azure通知中心。當試圖創建註冊時,我得到一個java.net.ConnectException:連接超時:沒有進一步的信息。有人能幫我理解爲什麼會出現這個問題嗎?請讓我知道你是否需要更多信息。謝謝。Azure通知中心java.net.ConnectException:連接超時:沒有進一步的信息

我使用的代碼是https://github.com/Azure/azure-notificationhubs-java-backend/blob/master/NotificationHubs

Jar文件版本如下:

httpclient - 4.3.1 
httpcore - 4.3.1 
httpcore-nio - 4.3.1 

錯誤發生在SyncCallback類,方法 - 「失敗」。異常跟蹤如下。

java.lang.RuntimeException: java.net.ConnectException: Connection timed out: no further information 
    at com.org.utils.notifications.SyncCallback.failed(SyncCallback.java:41) 
    at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:130) 
    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.connectionRequestFailed(DefaultClientExchangeHandlerImpl.java:318) 
    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.access$100(DefaultClientExchangeHandlerImpl.java:63) 
    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl$1.failed(DefaultClientExchangeHandlerImpl.java:364) 
    at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:130) 
    at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalPoolEntryCallback.failed(PoolingNHttpClientConnectionManager.java:474) 
    at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:130) 
    at org.apache.http.nio.pool.RouteSpecificPool.failed(RouteSpecificPool.java:165) 
    at org.apache.http.nio.pool.AbstractNIOConnPool.requestFailed(AbstractNIOConnPool.java:530) 
    at org.apache.http.nio.pool.AbstractNIOConnPool$InternalSessionRequestCallback.failed(AbstractNIOConnPool.java:778) 
    at org.apache.http.impl.nio.reactor.SessionRequestImpl.failed(SessionRequestImpl.java:154) 
    at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:175) 
    at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:147) 
    at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:349) 
    at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:189) 
    at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.doExecute(CloseableHttpAsyncClientBase.java:67) 
    at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.access$000(CloseableHttpAsyncClientBase.java:38) 
    at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:57) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: java.net.ConnectException: Connection timed out: no further information 
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 
    at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source) 
    at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:173) 
    ... 7 more 
+1

您可以檢查調試器在哪裏試圖連接並確保您可以通過命令行或任何其他方式進行調用?它可能是封閉的端口或防火牆阻止呼叫。 –

回答

1

你可以找到這個java.net.ConnectException: Connection timed out的一些共鳴例外。您的系統端口的

  1. 防火牆響了,你正在使用到項目中。 檢查您的filewale設置並取消阻止端口。

  2. IP /域或端口不正確。 嘗試使用pingtelnet命令來檢查連接性。

  3. 可能是由於互聯網速度慢或havy過程服務器不在時間段內處理請求,或者可能是連接問題。

+0

@ nikita-g/Mayank - 正如我剛纔提到的,它試圖連接到Azure通知中心來創建設備註冊。我通過郵遞員檢查了網址,它工作正常。我試圖在Eclipse + Tomcat服務器組合上運行代碼。 – csharpnewbie

+0

@csharpnewbie您的網絡環境中是否有代理服務器? Chrome/Postman將使用本地默認代理服務器設置來連接網絡,但Java除非通過方法'System.setProperty'來設置。 –

相關問題