Connect to cassandra cluster deployed on GCP










1















I have a 3 Node cluster running on GCP in Kubernetes. I am able to forward the port and connect with my DB Tool to the cluster:



$ kubectl port-forward elassandra-0 9042


When I try to connect to the cassandra cluster from my Spring Boot application, I get the following error:



2018-11-14 17:43:36,339 INFO [5914] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /10.4.3.3:9042 added
2018-11-14 17:43:36,339 INFO [5914] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /10.4.2.4:9042 added
2018-11-14 17:43:36,340 INFO [5915] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /127.0.0.1:9042 added
2018-11-14 17:43:41,391 WARN [10966] [cluster1-nio-worker-2] c.d.d.c.HostConnectionPool [HostConnectionPool.java:184] Error creating connection to /10.4.2.4:9042

com.datastax.driver.core.exceptions.TransportException: [/10.4.2.4:9042] Cannot connect
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:167)
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:150)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:504)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:483)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:121)


I am trying to connect to 127.0.0.1:9042, the other hosts are being pulled from the cluster by the spring-data framework.



What am I doing wrong here?



Thanks.










share|improve this question
























  • Your app is running in Kubernetes?

    – Rico
    Nov 14 '18 at 18:06











  • No. Local connect running on kubernetes (ClusteIP: none) works fine. I´m trying to find a way to connect from outside. For example for debugging puposes. Its connecting to the specified localhost with the portforwarding, but then the hosts returns the other 2 internal IP adresses, which cannot be directly reached from outside.

    – Alex Tbk
    Nov 14 '18 at 18:19
















1















I have a 3 Node cluster running on GCP in Kubernetes. I am able to forward the port and connect with my DB Tool to the cluster:



$ kubectl port-forward elassandra-0 9042


When I try to connect to the cassandra cluster from my Spring Boot application, I get the following error:



2018-11-14 17:43:36,339 INFO [5914] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /10.4.3.3:9042 added
2018-11-14 17:43:36,339 INFO [5914] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /10.4.2.4:9042 added
2018-11-14 17:43:36,340 INFO [5915] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /127.0.0.1:9042 added
2018-11-14 17:43:41,391 WARN [10966] [cluster1-nio-worker-2] c.d.d.c.HostConnectionPool [HostConnectionPool.java:184] Error creating connection to /10.4.2.4:9042

com.datastax.driver.core.exceptions.TransportException: [/10.4.2.4:9042] Cannot connect
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:167)
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:150)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:504)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:483)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:121)


I am trying to connect to 127.0.0.1:9042, the other hosts are being pulled from the cluster by the spring-data framework.



What am I doing wrong here?



Thanks.










share|improve this question
























  • Your app is running in Kubernetes?

    – Rico
    Nov 14 '18 at 18:06











  • No. Local connect running on kubernetes (ClusteIP: none) works fine. I´m trying to find a way to connect from outside. For example for debugging puposes. Its connecting to the specified localhost with the portforwarding, but then the hosts returns the other 2 internal IP adresses, which cannot be directly reached from outside.

    – Alex Tbk
    Nov 14 '18 at 18:19














1












1








1


1






I have a 3 Node cluster running on GCP in Kubernetes. I am able to forward the port and connect with my DB Tool to the cluster:



$ kubectl port-forward elassandra-0 9042


When I try to connect to the cassandra cluster from my Spring Boot application, I get the following error:



2018-11-14 17:43:36,339 INFO [5914] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /10.4.3.3:9042 added
2018-11-14 17:43:36,339 INFO [5914] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /10.4.2.4:9042 added
2018-11-14 17:43:36,340 INFO [5915] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /127.0.0.1:9042 added
2018-11-14 17:43:41,391 WARN [10966] [cluster1-nio-worker-2] c.d.d.c.HostConnectionPool [HostConnectionPool.java:184] Error creating connection to /10.4.2.4:9042

com.datastax.driver.core.exceptions.TransportException: [/10.4.2.4:9042] Cannot connect
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:167)
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:150)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:504)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:483)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:121)


I am trying to connect to 127.0.0.1:9042, the other hosts are being pulled from the cluster by the spring-data framework.



What am I doing wrong here?



Thanks.










share|improve this question
















I have a 3 Node cluster running on GCP in Kubernetes. I am able to forward the port and connect with my DB Tool to the cluster:



$ kubectl port-forward elassandra-0 9042


When I try to connect to the cassandra cluster from my Spring Boot application, I get the following error:



2018-11-14 17:43:36,339 INFO [5914] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /10.4.3.3:9042 added
2018-11-14 17:43:36,339 INFO [5914] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /10.4.2.4:9042 added
2018-11-14 17:43:36,340 INFO [5915] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /127.0.0.1:9042 added
2018-11-14 17:43:41,391 WARN [10966] [cluster1-nio-worker-2] c.d.d.c.HostConnectionPool [HostConnectionPool.java:184] Error creating connection to /10.4.2.4:9042

com.datastax.driver.core.exceptions.TransportException: [/10.4.2.4:9042] Cannot connect
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:167)
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:150)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:504)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:483)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:121)


I am trying to connect to 127.0.0.1:9042, the other hosts are being pulled from the cluster by the spring-data framework.



What am I doing wrong here?



Thanks.







cassandra kubernetes google-cloud-platform spring-data-cassandra






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 18:29







Alex Tbk

















asked Nov 14 '18 at 16:50









Alex TbkAlex Tbk

606623




606623












  • Your app is running in Kubernetes?

    – Rico
    Nov 14 '18 at 18:06











  • No. Local connect running on kubernetes (ClusteIP: none) works fine. I´m trying to find a way to connect from outside. For example for debugging puposes. Its connecting to the specified localhost with the portforwarding, but then the hosts returns the other 2 internal IP adresses, which cannot be directly reached from outside.

    – Alex Tbk
    Nov 14 '18 at 18:19


















  • Your app is running in Kubernetes?

    – Rico
    Nov 14 '18 at 18:06











  • No. Local connect running on kubernetes (ClusteIP: none) works fine. I´m trying to find a way to connect from outside. For example for debugging puposes. Its connecting to the specified localhost with the portforwarding, but then the hosts returns the other 2 internal IP adresses, which cannot be directly reached from outside.

    – Alex Tbk
    Nov 14 '18 at 18:19

















Your app is running in Kubernetes?

– Rico
Nov 14 '18 at 18:06





Your app is running in Kubernetes?

– Rico
Nov 14 '18 at 18:06













No. Local connect running on kubernetes (ClusteIP: none) works fine. I´m trying to find a way to connect from outside. For example for debugging puposes. Its connecting to the specified localhost with the portforwarding, but then the hosts returns the other 2 internal IP adresses, which cannot be directly reached from outside.

– Alex Tbk
Nov 14 '18 at 18:19






No. Local connect running on kubernetes (ClusteIP: none) works fine. I´m trying to find a way to connect from outside. For example for debugging puposes. Its connecting to the specified localhost with the portforwarding, but then the hosts returns the other 2 internal IP adresses, which cannot be directly reached from outside.

– Alex Tbk
Nov 14 '18 at 18:19













2 Answers
2






active

oldest

votes


















1














Answering own question:



You need to specify custom adress resolution driver side as described here:



https://docs.datastax.com/en/developer/java-driver/2.1/manual/address_resolution/



In detail when you want to use only one node:



public class MyAdressTranslator implements AddressTranslator 
@Override
public void init(Cluster cluster)

public InetSocketAddress translate(InetSocketAddress address)
return new InetSocketAddress("127.0.0.1", 9042);


@Override
public void close()






share|improve this answer






























    1














    To add more details since you have automatic address resolution enabled, your client it's trying to add contact points to all the nodes in your cluster:



    10.4.3.3:9042
    10.4.2.4:9042
    127.0.0.1:9042


    However, the top 2 nodes cannot be found from your localhost because they are not being proxied to. If you added them as proxies it wouldn't work either because you can't proxy on the same port from your laptop. The solution like @AlexTbk mentioned is to use a single contact point but specifying address resolution on the client with the single 127.0.0.1:9042 contact point.






    share|improve this answer






















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305127%2fconnect-to-cassandra-cluster-deployed-on-gcp%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Answering own question:



      You need to specify custom adress resolution driver side as described here:



      https://docs.datastax.com/en/developer/java-driver/2.1/manual/address_resolution/



      In detail when you want to use only one node:



      public class MyAdressTranslator implements AddressTranslator 
      @Override
      public void init(Cluster cluster)

      public InetSocketAddress translate(InetSocketAddress address)
      return new InetSocketAddress("127.0.0.1", 9042);


      @Override
      public void close()






      share|improve this answer



























        1














        Answering own question:



        You need to specify custom adress resolution driver side as described here:



        https://docs.datastax.com/en/developer/java-driver/2.1/manual/address_resolution/



        In detail when you want to use only one node:



        public class MyAdressTranslator implements AddressTranslator 
        @Override
        public void init(Cluster cluster)

        public InetSocketAddress translate(InetSocketAddress address)
        return new InetSocketAddress("127.0.0.1", 9042);


        @Override
        public void close()






        share|improve this answer

























          1












          1








          1







          Answering own question:



          You need to specify custom adress resolution driver side as described here:



          https://docs.datastax.com/en/developer/java-driver/2.1/manual/address_resolution/



          In detail when you want to use only one node:



          public class MyAdressTranslator implements AddressTranslator 
          @Override
          public void init(Cluster cluster)

          public InetSocketAddress translate(InetSocketAddress address)
          return new InetSocketAddress("127.0.0.1", 9042);


          @Override
          public void close()






          share|improve this answer













          Answering own question:



          You need to specify custom adress resolution driver side as described here:



          https://docs.datastax.com/en/developer/java-driver/2.1/manual/address_resolution/



          In detail when you want to use only one node:



          public class MyAdressTranslator implements AddressTranslator 
          @Override
          public void init(Cluster cluster)

          public InetSocketAddress translate(InetSocketAddress address)
          return new InetSocketAddress("127.0.0.1", 9042);


          @Override
          public void close()







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 18:42









          Alex TbkAlex Tbk

          606623




          606623























              1














              To add more details since you have automatic address resolution enabled, your client it's trying to add contact points to all the nodes in your cluster:



              10.4.3.3:9042
              10.4.2.4:9042
              127.0.0.1:9042


              However, the top 2 nodes cannot be found from your localhost because they are not being proxied to. If you added them as proxies it wouldn't work either because you can't proxy on the same port from your laptop. The solution like @AlexTbk mentioned is to use a single contact point but specifying address resolution on the client with the single 127.0.0.1:9042 contact point.






              share|improve this answer



























                1














                To add more details since you have automatic address resolution enabled, your client it's trying to add contact points to all the nodes in your cluster:



                10.4.3.3:9042
                10.4.2.4:9042
                127.0.0.1:9042


                However, the top 2 nodes cannot be found from your localhost because they are not being proxied to. If you added them as proxies it wouldn't work either because you can't proxy on the same port from your laptop. The solution like @AlexTbk mentioned is to use a single contact point but specifying address resolution on the client with the single 127.0.0.1:9042 contact point.






                share|improve this answer

























                  1












                  1








                  1







                  To add more details since you have automatic address resolution enabled, your client it's trying to add contact points to all the nodes in your cluster:



                  10.4.3.3:9042
                  10.4.2.4:9042
                  127.0.0.1:9042


                  However, the top 2 nodes cannot be found from your localhost because they are not being proxied to. If you added them as proxies it wouldn't work either because you can't proxy on the same port from your laptop. The solution like @AlexTbk mentioned is to use a single contact point but specifying address resolution on the client with the single 127.0.0.1:9042 contact point.






                  share|improve this answer













                  To add more details since you have automatic address resolution enabled, your client it's trying to add contact points to all the nodes in your cluster:



                  10.4.3.3:9042
                  10.4.2.4:9042
                  127.0.0.1:9042


                  However, the top 2 nodes cannot be found from your localhost because they are not being proxied to. If you added them as proxies it wouldn't work either because you can't proxy on the same port from your laptop. The solution like @AlexTbk mentioned is to use a single contact point but specifying address resolution on the client with the single 127.0.0.1:9042 contact point.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 14 '18 at 18:47









                  RicoRico

                  28.8k95369




                  28.8k95369



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305127%2fconnect-to-cassandra-cluster-deployed-on-gcp%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Use pre created SQLite database for Android project in kotlin

                      Darth Vader #20

                      Ondo