cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Community Platform Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

[Databricks][DatabricksJDBCDriver](500593) Communication link failure. Failed to connect to server.

violar
New Contributor

I am using databricks jdbc driver to run a certain app. It runs fine for a few mins to hours and then I get the error 
[Databricks][DatabricksJDBCDriver](500593) Communication link failure. Failed to connect to server. Reason: HTTP Response code: 502, Error message: Unknown. Any suggestions to resolve this issue?

Here is the stack trace

```
java.sql.SQLException: [Databricks][DatabricksJDBCDriver](500593) Communication link failure. Failed to connect to server. Reason: HTTP Response code: 502, Error message: Unknown.
at com.databricks.client.hivecommon.api.HS2Client.handleTTransportException(Unknown Source)
at com.databricks.client.spark.jdbc.DowloadableFetchClient.handleTTransportException(Unknown Source)
at com.databricks.client.hivecommon.api.HS2Client.openSession(Unknown Source)
at com.databricks.client.hivecommon.api.HS2Client.<init>(Unknown Source)
at com.databricks.client.spark.jdbc.DowloadableFetchClient.<init>(Unknown Source)
at com.databricks.client.spark.jdbc.DownloadableFetchClientFactory.createClient(Unknown Source)
at com.databricks.client.hivecommon.core.HiveJDBCCommonConnection.connectToServer(Unknown Source)
at com.databricks.client.spark.core.SparkJDBCConnection.connectToServer(Unknown Source)
at com.databricks.client.hivecommon.core.HiveJDBCCommonConnection.establishConnection(Unknown Source)
at com.databricks.client.spark.core.SparkJDBCConnection.establishConnection(Unknown Source)
at com.databricks.client.jdbc.core.LoginTimeoutConnection.connect(Unknown Source)
at com.databricks.client.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)
at com.databricks.client.jdbc.common.AbstractDriver.connect(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at world.data.external.jdbc.sandbox.ContextClassLoaderProxy.invoke(ContextClassLoaderProxy.java:82)
at jdk.proxy3/jdk.proxy3.$Proxy15.connect(Unknown Source)
Caused by: com.databricks.client.support.exceptions.ErrorException: [Databricks][DatabricksJDBCDriver](500593) Communication link failure. Failed to connect to server. Reason: HTTP Response code: 502, Error message: Unknown.
... 58 common frames omitted
Caused by: com.databricks.client.jdbc42.internal.apache.thrift.transport.TTransportException: HTTP Response code: 502, Error message: Unknown
at com.databricks.client.hivecommon.api.TETHttpClient.handleHeaderErrorMessage(Unknown Source)
at com.databricks.client.hivecommon.api.TETHttpClient.handleErrorResponse(Unknown Source)
at com.databricks.client.hivecommon.api.TETHttpClient.flushUsingHttpClient(Unknown Source)
at com.databricks.client.hivecommon.api.TETHttpClient.flush(Unknown Source)
at com.databricks.client.jdbc42.internal.apache.thrift.TServiceClient.sendBase(TServiceClient.java:73)
at com.databricks.client.jdbc42.internal.apache.thrift.TServiceClient.sendBase(TServiceClient.java:62)
at com.databricks.client.jdbc42.internal.apache.hive.service.rpc.thrift.TCLIService$Client.send_OpenSession(TCLIService.java:147)
at com.databricks.client.hivecommon.api.HS2ClientWrapper.send_OpenSession(Unknown Source)
at com.databricks.client.jdbc42.internal.apache.hive.service.rpc.thrift.TCLIService$Client.OpenSession(TCLIService.java:139)
at com.databricks.client.hivecommon.api.HS2ClientWrapper.callOpenSession(Unknown Source)
at com.databricks.client.hivecommon.api.HS2ClientWrapper.access$1700(Unknown Source)
at com.databricks.client.hivecommon.api.HS2ClientWrapper$18.clientCall(Unknown Source)
at com.databricks.client.hivecommon.api.HS2ClientWrapper$18.clientCall(Unknown Source)
at com.databricks.client.hivecommon.api.HS2ClientWrapper.executeWithRetry(Unknown Source)
at com.databricks.client.hivecommon.api.HS2ClientWrapper.OpenSession(Unknown Source)
... 56 common frames omitted

```

1 REPLY 1

Kaniz_Fatma
Community Manager
Community Manager

Hi @violarThe error youโ€™re encountering with the Databricks JDBC driver can be quite frustrating, but letโ€™s troubleshoot it together.

Here are a few suggestions to resolve this issue:

  1. Check Your Authentication Mechanism:

    • The error message indicates a communication link failure. One common cause is incorrect authentication. Ensure that youโ€™re using the correct authentication method.
    • In your Java code, youโ€™re explicitly passing the username and password to DriverManager.getConnection(url, username, password). However, Databricks typically uses tokens for authentication.
    • Try connecting without specifying the username and password:
      Connection connection = DriverManager.getConnection(url);
      
    • Make sure your token is valid and hasnโ€™t expired.
  2. Verify Token and URL:

    • Double-check that the token in your URL is correct. Regenerate the token if needed.
    • Ensure that the URL is accurate and points to the correct Databricks cluster.
  3. HTTP Response Code 502:

    • A 502 Bad Gateway error typically indicates an issue with the gateway server (e.g., reverse proxy or load balancer) between your client and the Databricks service.
    • Check for any network issues or if the Databricks service is experiencing problems.
  4. Network and Firewall Settings:

    • Ensure that your network allows outbound connections to the Databricks service.
    • Check if any firewall rules are blocking the communication.
  5. Driver Version Compatibility:

    • Verify that your Databricks JDBC driver version (com.databricks:databricks-jdbc) is compatible with your Databricks cluster version.
    • Consider updating the driver to a more recent version if needed.
  6. Thread Leakage (Advanced):

    • If you suspect thread leakage, ensure you close connections and resources appropriately.
    • Review your code to see if there are any unclosed connections or resources.

Remember to test each step after making changes. Hopefully, one of these suggestions will help you resolve the issue. If you continue to face problems, consider reaching out for further assistance. Good luck! ๐Ÿš€

 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group