We need to expose an additional property as the following is thrown when one wants to customize the contact points to use.
Caused by: java.lang.IllegalStateException: Since you provided explicit contact points, the local DC must be explicitly set (see basic.load-balancing-policy.local-datacenter in the config, or set it programmatically with SessionBuilder.withLocalDatacenter). Current contact points are: Node(endPoint=/127.0.0.1:9042, hostId=3e9d107c-8fab-4458-b217-d84c4491b574, hashCode=22d286ac)=datacenter1. Current DCs in this cluster are: datacenter1
at com.datastax.oss.driver.internal.core.loadbalancing.helper.MandatoryLocalDcHelper.discoverLocalDc(MandatoryLocalDcHelper.java:91) ~[java-driver-core-4.3.1.jar:na]
at com.datastax.oss.driver.internal.core.loadbalancing.DefaultLoadBalancingPolicy.discoverLocalDc(DefaultLoadBalancingPolicy.java:73) ~[java-driver-core-4.3.1.jar:na]
at com.datastax.oss.driver.internal.core.loadbalancing.BasicLoadBalancingPolicy.init(BasicLoadBalancingPolicy.java:126) ~[java-driver-core-4.3.1.jar:na]
at com.datastax.oss.driver.internal.core.metadata.LoadBalancingPolicyWrapper.init(LoadBalancingPolicyWrapper.java:121) ~[java-driver-core-4.3.1.jar:na]
at com.datastax.oss.driver.internal.core.session.DefaultSession$SingleThreaded.afterInitialSchemaRefresh(DefaultSession.java:419) ~[java-driver-core-4.3.1.jar:na]
at com.datastax.oss.driver.internal.core.session.DefaultSession$SingleThreaded.lambda$afterInitialNodeListRefresh$5(DefaultSession.java:409) ~[java-driver-core-4.3.1.jar:na]
at java.util.concurrent.CompletableFuture.uniAccept(CompletableFuture.java:670) ~[na:1.8.0_232]
at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:646) ~[na:1.8.0_232]
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488) ~[na:1.8.0_232]
at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975) ~[na:1.8.0_232]
at com.datastax.oss.driver.internal.core.metadata.MetadataManager$SingleThreaded.lambda$startSchemaRequest$2(MetadataManager.java:420) ~[java-driver-core-4.3.1.jar:na]
at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774) ~[na:1.8.0_232]
at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750) ~[na:1.8.0_232]
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488) ~[na:1.8.0_232]
at java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:575) ~[na:1.8.0_232]
at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:594) ~[na:1.8.0_232]
at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:456) ~[na:1.8.0_232]
at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) ~[netty-transport-4.1.43.Final.jar:4.1.43.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050) ~[netty-common-4.1.43.Final.jar:4.1.43.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.43.Final.jar:4.1.43.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.43.Final.jar:4.1.43.Final]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_232]
At the moment this even happens by default (i.e. without changing anything) so that's quite annoying.
Comment From: mp911de
@adutra can you have a look?
Comment From: snicoll
If I specify a local DC as instructed via a customizer, I get the following warning:
2020-01-16 14:11:43.970 WARN 30497 --- [ s0-admin-0] c.d.o.d.i.c.l.h.OptionalLocalDcHelper : [s0|default] You specified test as the local DC, but some contact points are from a different DC: Node(endPoint=/127.0.0.1:9042, hostId=3e9d107c-8fab-4458-b217-d84c4491b574, hashCode=27bd52ff)=datacenter1; please provide the correct local DC, or check your contact points
This is running with only the defaults targeting cassandra running on my machine.
Comment From: snicoll
If you specify a contact-point with a port, it seems it is ignored.
spring.data.cassandra.contact-points=localhost:4534
leads to
Caused by: com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 2, use getErrors() for more: Node(endPoint=localhost/0:0:0:0:0:0:0:1:4534, hostId=null, hashCode=7a1757e7): com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] init query OPTIONS: error writing , Node(endPoint=localhost/127.0.0.1:4534, hostId=null, hashCode=7929ae7a): com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] init query OPTIONS: error writing )
at com.datastax.oss.driver.api.core.AllNodesFailedException.copy(AllNodesFailedException.java:95) ~[java-driver-core-4.3.1.jar:na]
at com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures.getUninterruptibly(CompletableFutures.java:149) ~[java-driver-core-4.3.1.jar:na]
at com.datastax.oss.driver.api.core.session.SessionBuilder.build(SessionBuilder.java:501) ~[java-driver-core-4.3.1.jar:na]
at org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration.cassandraSession(CassandraAutoConfiguration.java:67) ~[spring-boot-autoconfigure-2.3.0.BUILD-20200116.094724-144.jar:2.3.0.BUILD-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_232]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_232]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_232]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_232]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
... 33 common frames omitted
However, the following
spring.data.cassandra.contact-points=something
starts the app just fine (as I happen to have cassandra running on the default port):
2020-01-16 14:16:56.216 INFO 32270 --- [ main] c.d.o.d.i.core.DefaultMavenCoordinates : DataStax Java driver for Apache Cassandra(R) (com.datastax.oss:java-driver-core) version 4.3.1
2020-01-16 14:16:56.600 INFO 32270 --- [ s0-admin-0] c.d.oss.driver.internal.core.time.Clock : Using native clock for microsecond precision
2020-01-16 14:16:56.603 INFO 32270 --- [ s0-admin-0] c.d.o.d.i.core.metadata.MetadataManager : [s0] No contact points provided, defaulting to /127.0.0.1:9042
Comment From: adutra
All DataStax drivers decided in the past years to move away from 1) built-in DC failover and 2) automatic local DC inference from contact points. In the Java driver, these decisions were applied starting with driver 4.0. This is because we firmly believe that both features can lead to misconfiguration issues.
The driver now requires from the user to explicitly specify the local DC. You can do so either through configuration with the option basic.load-balancing-policy.local-datacenter or programmatically, with SessionBuilder.withLocalDataCenter. Check our docs on load balancing for more information.
I would recommend that you also require from Spring users to explicitly define the local datacenter. If that’s not an option for you, the workaround would be to use an alternate load balancing policy that ships with the driver as well: DcInferringLoadBalancingPolicy. As its name implies, this LBP would assume that the local DC is whatever DC the contact points report. But this LBP is not meant as a general-purpose policy, it’s rather for analytics tools (Spark, mostly).
Requiring a local DC may pose problems for some of your tests because embedded Cassandra libraries tend to assign arbitrary datacenter names to test clusters. If that’s the case, the simplest solution is to actually not specify any contact point, in which case the default LBP will switch to “test mode” (so to speak) and assume that 1) the contact point is localhost and 2) the local DC is whatever DC that contact point reports.
Comment From: adutra
If I specify a local DC as instructed via a customizer, I get the following warning:
2020-01-16 14:11:43.970 WARN 30497 --- [ s0-admin-0] c.d.o.d.i.c.l.h.OptionalLocalDcHelper : [s0|default] You specified test as the local DC, but some contact points are from a different DC: Node(endPoint=/127.0.0.1:9042, hostId=3e9d107c-8fab-4458-b217-d84c4491b574, hashCode=27bd52ff)=datacenter1; please provide the correct local DC, or check your contact pointsThis is running with only the defaults targeting cassandra running on my machine.
The correct datacenter seems to be datacenter1 in your case, but you specified test instead. These misconfigurations are very common in real life, and the main reason why we decided to be more opinionated about datacenter names. Connecting to the wrong datacenter may be extremely impactful on performance.
Comment From: adutra
If you specify a contact-point with a port, it seems it is ignored.
init query OPTIONS: error writing most certainly means that the socket could not be opened, or an SSL handshake error happened. We improved the error messages in driver 4.4.0. In any case, the port is probably wrong.
starts the app just fine (as I happen to have cassandra running on the default port):
Do you mind double checking? It seems to me that the contact point wasn’t passed at all to the driver. This is why it reports “no contact points provided” and switches to “test mode”, which in turn makes the connection successful.
Comment From: jmooo
If anyone comes across this ticket googling the spring 2.3 local DC error, the spring config var you want is:
spring.data.cassandra.local-datacenter=datacenter1
(where datacenter1 is whatever you previously named your DC)
Comment From: m-kajiwara
When I specified multiple contact points, setLocalDatacenter set only the first one?
When I used DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER like CassandraAutoConfiguration, it's ok
Or addContactPoints(List).withLocalDatacenter()
String getContactPoints() {
return "cassandra-node1,cassandra-node2,cassandra-node3"
}
String getLocalDataCenter() {
return "dc1";
}
You specified dc1 as the local DC, but some contact points are from a different DC: Node(endPoint=cassandra-node2:9042, hostId=null, hashCode=)=null, Node(endPoint=cassandra-node3:9042, hostId=null, hashCode=)=null;
Comment From: snicoll
I think this is a question for the Cassandra support as things have changed quite a lot with the new driver. If they can’t help and you believe you’ve found an issue, please open a separate issue.
Comment From: adutra
When I specified multiple contact points, setLocalDatacenter set only the first one?
The local datacenter must be the same for all contact points.
It's hard to tell without more context, but it does look like you are hitting JAVA-2835. It will be fixed in the next driver release, 4.8.0, due in the next few days.
Comment From: mksmum
I am able to connect with localhost cassandra fine but when trying to connect shared cluster i am facing error connecting to node (endpoint:XXXXXXX like this. I am using spring boot data cassandra. I tried the property spring.data.cassandra.ssl=true as well but not luck. Could you please help me out.
Comment From: snicoll
@mksmum please follow up with the Cassandra support for this or ask a question on StackOverflow.
Comment From: ken4ward
If anyone comes across this ticket googling the spring 2.3 local DC error, the spring config var you want is:
spring.data.cassandra.local-datacenter=datacenter1(where
datacenter1is whatever you previously named your DC)
This is not working at all. I wonder why a simple config our of the box will create an unreliable problem. I have been one this issue for over 36 hours with not solution. I only added this lib, and added the properties yet the problem has refused to go. This is just so annoying. I'm using Spring-boot 2.4.5,
spring.data.cassandra.contact-points=127.0.0.1
spring.data.cassandra.username=cassandra
spring.data.cassandra.password=cassandra
spring.data.cassandra.keyspace=accountservicedb
spring.data.cassandra.port=9042
spring.data.cassandra.schema-action=NONE
spring.data.cassandra.local-datacenter=datacenter1
Comment From: snicoll
@ken4ward "not working at all" is not very helpful. Cassandra now requires a local DC and there's nothing we can do about it. If you have trouble configuring your access to Casandra, please follow-up with the Cassandra support as I've mentioned in the comment above yours. If you believe there is something in Spring Boot we can improve to make the experience more smooth, feel free to create a separate issue with additional details. Thank you.
Comment From: Vaishnav-puram
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.datastax.oss.driver.api.core.CqlSession]: Factory method 'cassandraSession' threw exception with message: Since you provided explicit contact points, the local DC must be explicitly set (see basic.load-balancing-policy.local-datacenter in the config, or set it programmatically with SessionBuilder.withLocalDatacenter). Current contact points are: Node(endPoint=/127.0.0.1:9042, hostId=0323221f-9a0f-ec92-ea4a-c1472c2a8b94, hashCode=c1b5137)=datacenter1. Current DCs in this cluster are: datacenter1
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:171) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648) ~[spring-beans-6.0.2.jar:6.0.2]
... 89 common frames omitted
Caused by: java.lang.IllegalStateException: Since you provided explicit contact points, the local DC must be explicitly set (see basic.load-balancing-policy.local-datacenter in the config, or set it programmatically with SessionBuilder.withLocalDatacenter). Current contact points are: Node(endPoint=/127.0.0.1:9042, hostId=0323221f-9a0f-ec92-ea4a-c1472c2a8b94, hashCode=c1b5137)=datacenter1. Current DCs in this cluster are: datacenter1
at com.datastax.oss.driver.internal.core.loadbalancing.helper.MandatoryLocalDcHelper.discoverLocalDc(MandatoryLocalDcHelper.java:91) ~[java-driver-core-4.11.4-yb-1-RC1.jar:na]
at com.datastax.oss.driver.internal.core.loadbalancing.DefaultLoadBalancingPolicy.discoverLocalDc(DefaultLoadBalancingPolicy.java:119) ~[java-driver-core-4.11.4-yb-1-RC1.jar:na]
at com.datastax.oss.driver.internal.core.loadbalancing.BasicLoadBalancingPolicy.init(BasicLoadBalancingPolicy.java:157) ~[java-driver-core-4.11.4-yb-1-RC1.jar:na]
at com.datastax.oss.driver.internal.core.loadbalancing.DefaultLoadBalancingPolicy.init(DefaultLoadBalancingPolicy.java:110) ~[java-driver-core-4.11.4-yb-1-RC1.jar:na]
at com.yugabyte.oss.driver.internal.core.loadbalancing.PartitionAwarePolicy.init(PartitionAwarePolicy.java:67) ~[java-driver-core-4.11.4-yb-1-RC1.jar:na]
at com.datastax.oss.driver.internal.core.metadata.LoadBalancingPolicyWrapper.init(LoadBalancingPolicyWrapper.java:121) ~[java-driver-core-4.11.4-yb-1-RC1.jar:na]
at com.datastax.oss.driver.internal.core.session.DefaultSession$SingleThreaded.initializePools(DefaultSession.java:471) ~[java-driver-core-4.11.4-yb-1-RC1.jar:na]
at com.datastax.oss.driver.internal.core.session.DefaultSession$SingleThreaded.lambda$init$5(DefaultSession.java:389) ~[java-driver-core-4.11.4-yb-1-RC1.jar:na]
at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147) ~[na:na]
at com.datastax.oss.driver.internal.core.metadata.MetadataManager$SingleThreaded.lambda$startSchemaRequest$1(MetadataManager.java:469) ~[java-driver-core-4.11.4-yb-1-RC1.jar:na]
at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:614) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:653) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[na:na]
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[netty-common-4.1.85.Final.jar:4.1.85.Final]
at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) ~[netty-transport-4.1.85.Final.jar:4.1.85.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.85.Final.jar:4.1.85.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.85.Final.jar:4.1.85.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.85.Final.jar:4.1.85.Final]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Process finished with exit code 1
Comment From: Vaishnav-puram
i even added the config file which works locally fine , but in the stg env it unable to reach the contact point and resulted in the following error :
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'session' defined in class path resource [com/rakuten/rmdp/access/config/CassandraConfig.class]: Failed to instantiate [com.datastax.oss.driver.api.core.CqlSession]: Factory method 'session' threw exception with message: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/[240b:c0e0:102:5dd8:b412:2:1:0]:32758, hostId=null, hashCode=994426b): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|id: 0x9dc095ff, L:/[240b:c0e0:102:5dd7:b412:2:0:42f6]:58160 - R:/[240b:c0e0:102:5dd8:b412:2:1:0]:32758] Protocol initialization request, step 1 (OPTIONS): unexpected failure (com.datastax.oss.driver.api.core.connection.ClosedConnectionException: Lost connection to remote peer)]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:793) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:242) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1188) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:412) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1324) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1161) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:880) ~[spring-beans-6.0.2.jar!/:6.0.2]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:784) ~[spring-beans-6.0.2.jar!/:6.0.2]
... 25 common frames omitted
Comment From: wilkinsona
@Vaishnav-puram The second exception indicates that the connection was closed, perhaps by the remote peer. That's out of Spring Boot's control. If you're looking for some help with Cassandra connectivity, I would recommend asking on Stack Overflow.
Comment From: Vaishnav-puram
but with the previous deployments it was working fine , i doubt this is because of the upgrade i did
On Fri, 27 Jan 2023 at 18:15, Andy Wilkinson @.***> wrote:
@Vaishnav-puram https://github.com/Vaishnav-puram The second exception indicates that the connection was closed, perhaps by the remote peer. That's out of Spring Boot's control. If you're looking for some help with Cassandra connectivity, I would recommend asking on Stack Overflow.
— Reply to this email directly, view it on GitHub https://github.com/spring-projects/spring-boot/issues/19779#issuecomment-1406464466, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALXLLMLO7YN775MYC66PFSTWUO7P5ANCNFSM4KHTXV2Q . You are receiving this because you were mentioned.Message ID: @.***>
Comment From: Vaishnav-puram
even i mentioned the contact-points and all it could'nt reach any contact-point I've created an issue on stack overflow pls review it
https://stackoverflow.com/questions/75258281/unable-to-connect-to-cassandra-from-spring-boot-application-with-spring-boot-v3
On Fri, 27 Jan 2023 at 18:15, Andy Wilkinson @.***> wrote:
@Vaishnav-puram https://github.com/Vaishnav-puram The second exception indicates that the connection was closed, perhaps by the remote peer. That's out of Spring Boot's control. If you're looking for some help with Cassandra connectivity, I would recommend asking on Stack Overflow.
— Reply to this email directly, view it on GitHub https://github.com/spring-projects/spring-boot/issues/19779#issuecomment-1406464466, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALXLLMLO7YN775MYC66PFSTWUO7P5ANCNFSM4KHTXV2Q . You are receiving this because you were mentioned.Message ID: @.***>
Comment From: wilkinsona
@Vaishnav-puram Please stop spamming the issue with multiple comments in quick succession. There's also no need to repeatedly mention people. If you continue to do so, we will have no choice but to lock this issue.
I looked at your Stack Overflow question on Friday. Unfortunately, it didn't provide enough information for me to be able to help you. I would recommend reviewing Stack Overflow's documentation on asking questions, particularly about how to ask a good question and on creating a minimal, reproducible example.
Comment From: Vaishnav-puram
@wilkinsona sorry for the actions of mine but i've updated the issue pls check and give any solution for it https://stackoverflow.com/questions/75258281/since-you-provided-explicit-contact-points-the-local-dc-must-be-explicitly-set
Comment From: Vaishnav-puram
I've updated my spring-boot to v3.0.0 and spring-data-cassandra to v4.0.0 which resulted in unable to connect to cassandra cluster which is deployed in stg env and runs on IPv6 address having different datacenter rather DC1 I've added a config file which accepts localDC programatically
@Bean(destroyMethod = "close")
public CqlSession session() {
CqlSession session = CqlSession.builder()
.addContactPoint(InetSocketAddress.createUnresolved("[240b:c0e0:1xx:xxx8:xxxx:x:x:x]", port))
.withConfigLoader(
DriverConfigLoader.programmaticBuilder()
.withString(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER, localDatacenter) .withString(DefaultDriverOption.AUTH_PROVIDER_USER_NAME,username)
.withString(DefaultDriverOption.AUTH_PROVIDER_PASSWORD,password)
.withString(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT,"10s")
.withString(DefaultDriverOption.CONNECTION_CONNECT_TIMEOUT, "20s")
.withString(DefaultDriverOption.REQUEST_TIMEOUT, "20s")
.withString(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT, "20s")
.withString(DefaultDriverOption.SESSION_KEYSPACE,keyspace)
.build())
//.addContactPoint(InetSocketAddress.createUnresolved(InetAddress.getByName(contactPoints).getHostName(), port))
.build();
}
return session;
and this is my application.yml file
spring:
data:
cassandra:
keyspace-name: xxx
contact-points: [xxxx:xxxx:xxxx:xxx:xxx:xxx]
port: xxx
local-datacenter: xxxx
use-dc-aware: true
username: xxxxx
password: xxxxx
ssl: true
SchemaAction: CREATE_IF_NOT_EXISTS
So locally I was able to connect to cassandra (by default it is pointing to localhost) , but in stg env my appplication is not able to connect to that cluster
logs in my stg env
caused by: com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node (endPoint=/[240b:cOe0:102:xxxx:xxxx:x:x:x]:3xxx,hostId-null,hashCode=4e9ba6a8):[com.datastax.oss.driver.api.core.connection.ConnectionInitException:[s0|controllid:0x984419ed,L:/[240b:cOe0:102:5dd7: xxxx:x:x:xxx]:4xxx - R:/[240b:c0e0:102:xxxx:xxxx:x:x:x]:3xxx] Protocol initialization request, step 1 (OPTIONS: unexpected tarlure com.datastax.oss.driver.apt.core.connection.closedconnectiontxception: Lost connection to remote peer)]