Azure / azure-cosmosdb-java

Java Async SDK for SQL API of Azure Cosmos DB
MIT License
54 stars 61 forks source link

java.net.UnknownHostException and org.apache.http.conn.HttpHostConnectException, while connecting to Azure cosmos db from Java #297

Closed ashmit-github001 closed 4 years ago

ashmit-github001 commented 4 years ago

BulkImport.java.txt

I'm facing an issue here.

I've created a simple Java project in eclipse. And added the JARs to the classpath. In the file BulkImport.java, I'm trying to connect to the Azure Cosmos DB. However, I'm running into the following error.

Warning : [main] WARN com.microsoft.azure.documentdb.GlobalEndpointManager - Failed to retrieve database account information. com.microsoft.azure.documentdb.DocumentClientException: java.net.UnknownHostException: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server.

The error occurs at this line :

DocumentClient client = new DocumentClient(ENDPOINT, PRIMARY_KEY, connectionPolicy, ConsistencyLevel.Session); The Endpoint looks like this : "https://xxxx.documents.azure.com:443"

Later on instead of this endpoint, I directly gave,"https://IPAddress:443". So I got the following error.

WARN com.microsoft.azure.documentdb.DocumentClient - Failed to retrieve database account information. org.apache.http.conn.HttpHostConnectException: Connect to"https://IP Address :443" failed: Connection refused: connect

I've attached the code file. Please help me understand the issue.

@moderakh