Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help : Client creation fails with Json Exception #137

Open
Ankzz opened this issue Apr 26, 2020 · 0 comments
Open

Need help : Client creation fails with Json Exception #137

Ankzz opened this issue Apr 26, 2020 · 0 comments

Comments

@Ankzz
Copy link

Ankzz commented Apr 26, 2020

Tried with two versions of 'azure-documentdb' library : 2.4.7 and 2.3.0 . Same error.

When I am trying to create a client object of type DocumentClient , I receive following error:
HTTP/1.1 404 Not Found for the initial request to read information from the Cosmos-Db.

Code used is as simple as:

docClient = new DocumentClient("https://xxx.mongo.cosmos.azure.com:443/", "<primary-key>", null /* Providing a policy also did made no difference */ , ConsistencyLevel.Session);

Following error is received:
01:22:16.635 [main] INFO com.microsoft.azure.documentdb.DocumentClient - Initializing DocumentClient with serviceEndpoint [https://xxx.mongo.cosmos.azure.com:443/], ConnectionPolicy [ConnectionPolicy [requestTimeout=10, directRequestTimeout10, mediaRequestTimeout=300, connectionMode=DirectHttps, mediaReadMode=Buffered, maxPoolSize=800, idleConnectionTimeout=60, userAgentSuffix=, retryOptions=com.microsoft.azure.documentdb.RetryOptions@20398b7c, enableEndpointDiscovery=true, preferredLocations=null, usingMultipleWriteLocations=false, handleServiceUnavailableFromProxy=false]], ConsistencyLevel [Session] 01:22:17.159 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context 01:22:17.159 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://xxx.mongo.cosmos.azure.com:443][total kept alive: 0; route allocated: 0 of 800; total allocated: 0 of 800] 01:22:17.168 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://xxx.mongo.cosmos.azure.com:443][total kept alive: 0; route allocated: 1 of 800; total allocated: 1 of 800] 01:22:17.169 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://xxx.mongo.cosmos.azure.com:443 01:22:17.332 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to xxx.mongo.cosmos.azure.com/xx.xx.xx.xx:443 01:22:17.332 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to xxx.mongo.cosmos.azure.com/xx.xx.xx.xx:443 with timeout 10000 01:22:17.639 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2] 01:22:17.639 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_EMPTY_RENEGOTIATION_INFO_SCSV] 01:22:17.639 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Starting handshake 01:22:18.237 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Secure session established 01:22:18.237 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - negotiated protocol: TLSv1.2 01:22:18.237 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 01:22:18.238 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - peer principal: CN=*.table.cosmosdb.azure.com 01:22:18.238 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - peer alternative names: [*.gremlin.cosmosdb.azure.com, *.cassandra.cosmosdb.azure.com, *.table.cosmosdb.azure.com, *.sql.cosmosdb.azure.com, *.etcd.cosmosdb.azure.com, *.gremlin.cosmos.azure.com, *.mongo.cosmos.azure.com, *.cassandra.cosmos.azure.com, *.table.cosmos.azure.com, *.sql.cosmos.azure.com, *.etcd.cosmos.azure.com, *.documents.azure.com] 01:22:18.238 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - issuer principal: CN=Microsoft IT TLS CA 2, OU=Microsoft IT, O=Microsoft Corporation, L=Redmond, ST=Washington, C=US 01:22:18.242 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 192.168.1.7:62386<->40.83.137.191:443 01:22:18.242 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 10000 01:22:18.242 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request GET / HTTP/1.1 01:22:18.242 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED 01:22:18.244 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> GET / HTTP/1.1 01:22:18.244 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> x-ms-version: 2018-09-17 01:22:18.244 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Cache-Control: no-cache 01:22:18.244 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Windows10/10.0 JRE/1.8.0_241 documentdb-java-sdk/2.3.0 01:22:18.244 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> x-ms-consistency-level: Session 01:22:18.244 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> authorization: type%3Dmaster%26ver%3D1.0%26sig%3Drm2cvkJRHj%2FNTcBOcjOHaYUKIKg3%2BqULmOUn9PD3z8Y%3D 01:22:18.244 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept: application/json 01:22:18.244 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> x-ms-date: Sun, 26 Apr 2020 19:52:17 GMT 01:22:18.244 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: xxxx.mongo.cosmos.azure.com:443 01:22:18.244 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive 01:22:18.244 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate 01:22:18.244 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "GET / HTTP/1.1[\r][\n]" 01:22:18.244 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "x-ms-version: 2018-09-17[\r][\n]" 01:22:18.244 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Cache-Control: no-cache[\r][\n]" 01:22:18.244 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Windows10/10.0 JRE/1.8.0_241 documentdb-java-sdk/2.3.0[\r][\n]" 01:22:18.244 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "x-ms-consistency-level: Session[\r][\n]" 01:22:18.244 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "authorization: type%3Dmaster%26ver%3D1.0%26sig%3Drm2cvkJRHj%2FNTcBOcjOHaYUKIKg3%2BqULmOUn9PD3z8Y%3D[\r][\n]" 01:22:18.244 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept: application/json[\r][\n]" 01:22:18.244 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "x-ms-date: Sun, 26 Apr 2020 19:52:17 GMT[\r][\n]" 01:22:18.245 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: xxx.mongo.cosmos.azure.com:443[\r][\n]" 01:22:18.245 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]" 01:22:18.245 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]" 01:22:18.245 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]" 01:22:18.500 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 404 Not Found[\r][\n]" 01:22:18.500 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Transfer-Encoding: chunked[\r][\n]" 01:22:18.501 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Server: Microsoft-HTTPAPI/2.0[\r][\n]" 01:22:18.501 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Sun, 26 Apr 2020 19:52:18 GMT[\r][\n]" 01:22:18.501 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]" 01:22:18.501 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "0[\r][\n]" 01:22:18.501 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]" 01:22:18.507 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 404 Not Found 01:22:18.507 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Transfer-Encoding: chunked 01:22:18.507 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Server: Microsoft-HTTPAPI/2.0 01:22:18.507 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Sun, 26 Apr 2020 19:52:18 GMT 01:22:18.519 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive indefinitely 01:22:18.525 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection [id: 0][route: {s}->https://xxx.mongo.cosmos.azure.com:443] can be kept alive indefinitely 01:22:18.525 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {s}->https://xxx.mongo.cosmos.azure.com:443][total kept alive: 1; route allocated: 1 of 800; total allocated: 1 of 800] 01:22:18.532 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Cancelling request execution Exception in thread "main" java.lang.IllegalArgumentException: Invalid JSON String: '' at com.microsoft.azure.documentdb.JsonSerializable.<init>(JsonSerializable.java:76) at com.microsoft.azure.documentdb.Resource.<init>(Resource.java:43) at com.microsoft.azure.documentdb.Error.<init>(Error.java:22) at com.microsoft.azure.documentdb.internal.ErrorUtils.maybeThrowException(ErrorUtils.java:60) at com.microsoft.azure.documentdb.internal.GatewayProxy.performGetRequest(GatewayProxy.java:242) at com.microsoft.azure.documentdb.internal.GatewayProxy.doRead(GatewayProxy.java:93) at com.microsoft.azure.documentdb.DocumentClient.getDatabaseAccountFromEndpointPrivate(DocumentClient.java:3163) at com.microsoft.azure.documentdb.DocumentClient.getDatabaseAccountFromEndpoint(DocumentClient.java:3151) at com.microsoft.azure.documentdb.GlobalEndpointManager$1.getDatabaseAccountFromEndpoint(GlobalEndpointManager.java:55) at com.microsoft.azure.documentdb.GlobalEndpointManager.getDatabaseAccountFromAnyEndpoint(GlobalEndpointManager.java:121) at com.microsoft.azure.documentdb.internal.BaseDatabaseAccountConfigurationProvider.<init>(BaseDatabaseAccountConfigurationProvider.java:22) at com.microsoft.azure.documentdb.DocumentClient.createBaseDatabaseAccountConfigurationProvider(DocumentClient.java:377) at com.microsoft.azure.documentdb.DocumentClient.initialize(DocumentClient.java:336) at com.microsoft.azure.documentdb.DocumentClient.<init>(DocumentClient.java:234) at com.microsoft.azure.documentdb.DocumentClient.<init>(DocumentClient.java:132) at com.eysamples.serverless.ss.service.CosmoDbClient.<init>(CosmoDbClient.java:23) at com.eysamples.serverless.ss.service.CosmoDbClient.main(CosmoDbClient.java:38) Caused by: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1] at org.json.JSONTokener.syntaxError(JSONTokener.java:433) at org.json.JSONObject.<init>(JSONObject.java:194) at org.json.JSONObject.<init>(JSONObject.java:321) at com.microsoft.azure.documentdb.JsonSerializable.<init>(JsonSerializable.java:74) ... 16 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant