Azure StorageException:发生未知故障:连接超时:连接

时间:2017-07-04 09:00:55

标签: java azure blob

我正在创建小型JAVA程序来访问Azure blob存储,如下所示。

但是,我可以使用Storage Explorer(具有相同的连接字符串)访问相同的存储

但是我没能在eclipse中使用JAVA代码访问它。

CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);    

CloudBlobClient serviceClient = account.createCloudBlobClient();

// Container name must be lower case.
CloudBlobContainer container = serviceClient.getContainerReference("testeventdata");

// Download the JSON file.
CloudBlockBlob blob = container.getBlockBlobReference("TEST2.json");

// Download file
File sourceFile = new File("d:\\LHWMSGDownLoad.json");

File destinationFile = new File(sourceFile.getParentFile(),
                            "TESTDownLoad.json");

// **** On following line I am getting ERROR *****
// *********************************************** 
blob.downloadToFile(destinationFile.getAbsolutePath());

错误说明:

StorageException encountered: com.microsoft.azure.storage.StorageException: An unknown failure occurred : Connection timed out: connect
    at com.microsoft.azure.storage.StorageException.translateException(StorageException.java:66)
    at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:200)`enter code here`
    at com.microsoft.azure.storage.blob.CloudBlob.download(CloudBlob.java:1083)
    at com.microsoft.azure.storage.blob.CloudBlob.downloadToFile(CloudBlob.java:1771)
    at com.microsoft.azure.storage.blob.CloudBlob.downloadToFile(CloudBlob.java:1743)
    at com.iot.tme.EventDataBlobAccess.EventDataBlobAccess.main(EventDataBlobAccess.java:67)
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.connect(Unknown Source`enter code here`)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
    at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:119)
    ... 4 more

1 个答案:

答案 0 :(得分:0)

根据我的经验,我认为这显然不是您的代码错误,但可能是由本地计算机或网络环境上的某些配置引起的,例如阻止来自Java的请求的防火墙。请检查并确认这些可能的系统配置或软件是否阻止它。