0

I am creating small JAVA program to access Azure blob storage as follows.

However I can able to access same Storage using Storage explorer (with same connection string)

But am failing to access the same with JAVA code in eclipse.

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

Error Description:

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
Peter Pan
  • 23,476
  • 4
  • 25
  • 43
Milind Pardeshi
  • 143
  • 2
  • 3
  • 10

1 Answers1

0

Per my experience, I think it's not your code fault obviously, but it might be caused by some configuration on your local machine or network environment very likely, such as firewall to block the request from Java. Please inspect and make sure whether these possible system configuration or softwares block it.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43