<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Connect to Databricks using Java SDK through proxy in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/connect-to-databricks-using-java-sdk-through-proxy/m-p/59929#M6547</link>
    <description>&lt;P&gt;I'm trying to connect to databricks from java using the java sdk and get cluster/sqlWarehouse state. I'm able to connect and get cluster state from my local. But, once I deploy it to the server, my company's network is not allowing the connection. We need to use proxy here but I'm not sure how to use proxy with the databricks java sdk.&lt;/P&gt;&lt;P&gt;Below is the code that works in local env:&lt;/P&gt;&lt;P&gt;DatabricksConfig config = new DatabricksConfig().setHost("&lt;A href="https://name.databricks.com" target="_blank" rel="noopener"&gt;https://name.databricks.com&lt;/A&gt;").setToken("myToken").resolve();&lt;/P&gt;&lt;P&gt;WorkspaceClient wc = new WorkspaceClient (config); wc.clusters().get("myClusterId").getState().toString();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any hint or suggestion would be very helpful.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Feb 2024 14:05:33 GMT</pubDate>
    <dc:creator>Nagasundaram</dc:creator>
    <dc:date>2024-02-12T14:05:33Z</dc:date>
    <item>
      <title>Connect to Databricks using Java SDK through proxy</title>
      <link>https://community.databricks.com/t5/get-started-discussions/connect-to-databricks-using-java-sdk-through-proxy/m-p/59929#M6547</link>
      <description>&lt;P&gt;I'm trying to connect to databricks from java using the java sdk and get cluster/sqlWarehouse state. I'm able to connect and get cluster state from my local. But, once I deploy it to the server, my company's network is not allowing the connection. We need to use proxy here but I'm not sure how to use proxy with the databricks java sdk.&lt;/P&gt;&lt;P&gt;Below is the code that works in local env:&lt;/P&gt;&lt;P&gt;DatabricksConfig config = new DatabricksConfig().setHost("&lt;A href="https://name.databricks.com" target="_blank" rel="noopener"&gt;https://name.databricks.com&lt;/A&gt;").setToken("myToken").resolve();&lt;/P&gt;&lt;P&gt;WorkspaceClient wc = new WorkspaceClient (config); wc.clusters().get("myClusterId").getState().toString();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any hint or suggestion would be very helpful.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 14:05:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/connect-to-databricks-using-java-sdk-through-proxy/m-p/59929#M6547</guid>
      <dc:creator>Nagasundaram</dc:creator>
      <dc:date>2024-02-12T14:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Databricks using Java SDK through proxy</title>
      <link>https://community.databricks.com/t5/get-started-discussions/connect-to-databricks-using-java-sdk-through-proxy/m-p/60183#M6549</link>
      <description>&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Hi&amp;nbsp;&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/99577"&gt;@Nagasundaram&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;You can make use of the below init script inorder to use a proxy server with Databricks cluster. The content of the init script can be added at&amp;nbsp; "Workspace/shared/setproxy.sh"&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;==================================================&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;SPAN&gt;val&amp;nbsp;proxy&amp;nbsp;=&amp;nbsp;"&lt;/SPAN&gt;&lt;A href="http://localhost:8888/" target="_blank"&gt;&lt;SPAN&gt;http://localhost:8888&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;"&amp;nbsp;//&amp;nbsp;set&amp;nbsp;this&amp;nbsp;to&amp;nbsp;your&amp;nbsp;actual&amp;nbsp;proxy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;val&amp;nbsp;proxy_host&amp;nbsp;=&amp;nbsp;"localhost"&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;val&amp;nbsp;proxy_port&amp;nbsp;=&amp;nbsp;"8888"&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;val&amp;nbsp;no_proxy&amp;nbsp;=&amp;nbsp;"127.0.0.1,.local,169.254.169.254,s3.amazonaws.com,s3.us-east-1.amazonaws.com"&amp;nbsp;// make sure to update no proxy as needed (e.g. for S3 region or any other internal domains)&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;val&amp;nbsp;java_no_proxy&amp;nbsp;=&amp;nbsp;"localhost|127.*|[::1]|169.254.169.254|s3.amazonaws.com|*.s3.amazonaws.com|s3.us-east-1.amazonaws.com|*.s3.us-east-1.amazonaws.com|10.*"&amp;nbsp;// replace 10.* with cluster IP range!!!!!!&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;dbutils.fs.put("Workspace/shared/setproxy.sh", s"""#!/bin/bash&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo "export http_proxy=$proxy" &amp;gt;&amp;gt; /databricks/spark/conf/spark-env.sh&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo "export https_proxy=$proxy" &amp;gt;&amp;gt; /databricks/spark/conf/spark-env.sh&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo "export no_proxy=$no_proxy" &amp;gt;&amp;gt; /databricks/spark/conf/spark-env.sh&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo "export HTTP_PROXY=$proxy" &amp;gt;&amp;gt; /databricks/spark/conf/spark-env.sh&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo "export HTTPS_PROXY=$proxy" &amp;gt;&amp;gt; /databricks/spark/conf/spark-env.sh&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo "export NO_PROXY=$no_proxy" &amp;gt;&amp;gt; /databricks/spark/conf/spark-env.sh&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo "export&amp;nbsp;_JAVA_OPTIONS=\"-Dhttps.proxyHost=${proxy_host} -Dhttps.proxyPort=${proxy_port} -Dhttp.proxyHost=${proxy_host} -Dhttp.proxyPort=${proxy_port} -Dhttp.nonProxyHosts=${java_no_proxy}\""&amp;nbsp;&amp;gt;&amp;gt; /databricks/spark/conf/spark-env.sh&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo&amp;nbsp;"http_proxy=$proxy"&amp;nbsp;&amp;gt;&amp;gt; /etc/environment&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo&amp;nbsp;"https_proxy=$proxy"&amp;nbsp;&amp;gt;&amp;gt; /etc/environment&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo&amp;nbsp;"no_proxy=$no_proxy"&amp;nbsp;&amp;gt;&amp;gt; /etc/environment&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo&amp;nbsp;"HTTP_PROXY=$proxy"&amp;nbsp;&amp;gt;&amp;gt; /etc/environment&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo&amp;nbsp;"HTTPS_PROXY=$proxy"&amp;nbsp;&amp;gt;&amp;gt; /etc/environment&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;echo&amp;nbsp;"NO_PROXY=$no_proxy"&amp;nbsp;&amp;gt;&amp;gt; /etc/environment&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;cat &amp;gt;&amp;gt; /etc/R/Renviron &amp;lt;&amp;lt; EOF&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;http_proxy=$proxy&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;https_proxy=$proxy&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;no_proxy=$no_proxy&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;EOF&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;""",&amp;nbsp;true)&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;==================================================&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Please test it carefully in your environment.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Let me know if that helps.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 10:13:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/connect-to-databricks-using-java-sdk-through-proxy/m-p/60183#M6549</guid>
      <dc:creator>Allia</dc:creator>
      <dc:date>2024-02-14T10:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Databricks using Java SDK through proxy</title>
      <link>https://community.databricks.com/t5/get-started-discussions/connect-to-databricks-using-java-sdk-through-proxy/m-p/60403#M6550</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply. I tried adding the arguments in manifest.yml file like this:&lt;/P&gt;&lt;P&gt;JAVA_OPTS:&amp;nbsp;"-Dhttp.proxyHost='your_proxy_hos't -Dhttp.proxyPort='your_proxy_port' -Dhttps.proxyHost='your_proxy_host' -Dhttps.proxyPort='your_proxy_port'"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still, I'm getting connection refused to databricks when I deploy this to PCF.&lt;/P&gt;&lt;P&gt;Is using WorkspaceClient the right way? Or, do I need to use AccountClient?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 11:58:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/connect-to-databricks-using-java-sdk-through-proxy/m-p/60403#M6550</guid>
      <dc:creator>Nagasundaram</dc:creator>
      <dc:date>2024-02-16T11:58:27Z</dc:date>
    </item>
  </channel>
</rss>

