I'm using Spring Boot to connect to Redis, every time I try to write into Redis I got this error MasterReplicaTopologyRefresh - Unable to connect to 172.21.0.3:6379, it's trying to contact the wrong server several times it sends 4 requests after 4 seconds.
Is there a way to stop or override the default host and port?
Thanks in advance
The issue came from readFrom(ReadFrom.MASTER) after removing it, it worked fine, when it is enabled the connection config keeps try to connect to the master
LettuceClientConfiguration lettuceClientConfiguration = LettuceClientConfiguration.builder()
//.readFrom(ReadFrom.MASTER)
.commandTimeout(Duration.ofSeconds(120))
.clientOptions(clusterClientOptions)
.build();
Related
I am getting started with Spring Boot and Spring Data Couchbase and I am having problems to connect to my couchbase server.
I using IntelliJ and I have used the Spring Initialzr to create my project.
Here's my configuration (I am using Kotlin):
#Configuration
class Config : AbstractCouchbaseConfiguration() {
override fun getBootstrapHosts(): List<String> = Collections.singletonList("10.0.0.10")
override fun getBucketName(): String = "cwp"
override fun getBucketPassword(): String = "password"
}
But instead of "just connecting" to the given ip there seems to be some reverse dns and so on in place which resolves wrong ips (due to routers and vpn) and so I am getting the following errors:
[CWSRV.fritz.box:8091][ConfigEndpoint]: Socket connect took longer than specified timeout: connection timed out: CWSRV.fritz.box/10.0.0.112:8091
The name of my server is CWSRV and I am using a vpn between my routers (Fritzboxes)
To omit such problems I want to use just the ip without any mishmash.
Any help would be appreciated!
I figured it out myself:
It seems that the Java SDK does a reverse DNS lookup if it gets an IP address. Since I had not reverse zone created in my DNS server it resolved to the router on the server side which return cwsrv.fritz.box. That resolved to 10.0.0.112 (instead of 10.0.0.10 - my server could have had this ip address assigned from the router any time in the past) and there no Couchbase server responded).
I created an entry of the server in my DNS and it works.
Resolution: Since the Couchbase (Java) SDK seems to rely on properly configured DNS make sure that Forward and Reverse lookups work as expected! :)
In spring Documentation --> 32.6 TCP Adapters it is mentioned that we use clientMode = "true" then the inbound adapter is responsible for the connection with external server.
I have created a flow in which the TCP Adapter with client connection factory makes connection with external server the code for the flow is :
IntegrationFlow flow = IntegrationFlows.from(Tcp.inboundAdapter(Tcp.nioClient(hostConnection.getIpAddress(),Integer.parseInt(hostConnection.getPort()))
.serializer(customSerializer)
.deserializer(customSerializer)
.id(hostConnection.getConnectionNumber())).clientMode(true).retryInterval(1000).errorChannel("testChannel").id(hostConnection.getConnectionNumber()+"adapter"))
.enrichHeaders(f->f.header("CustomerCode",hostConnection.getConnectionNumber()))
.channel(directChannel())
.handle(Jms.outboundAdapter(ConnectionFactory())
.destination(hostConnection.getConnectionNumber()))
.get();
theFlow = this.flowContext.registration(flow).id(hostConnection.getConnectionNumber()+"outflow").register();
I have created multiple flow by iterating over the list of connections and
iterate the above code in for loop and register them in flowcontext with unique ID.
My clients are created successfully with no issue and then establish there connection as supported by topology.
Issue :
I have counted the number of client connection created successfully so I have counted that 7 client connection (7 Integration flow) made successfully and they initiate connection from themselves.
when I create 8th client connection (8th flow created and registered successfully) but the .clientMode(true) is not working means the client don't initiate connection itself after first failure means it try for the first time to make connection if connected successfully then no issue but in case of failure it don't retry again.
Also my other created clients i.e 7 clients connection which are created successfully they also stopped initiating connection from itself when they got disconnected.
Note: There is no issue with flow only the TCP Adapters they stop initiating the connection
The flow is created and registered successfully as there is no issue it is because when I run a control bus command #adapter_id.retryConnection() it got connected with the server.
I don't understand that what is the issue with my flow that i couldn't initiate a connection after a particular count i.e seven or is there limitation in creating number of clients.
One possibility is the taskScheduler's thread pool is exhausted - that shouldn't happen with the above configuration, but it depends on what else is in the application. Take a thread dump (e.g. jstack) to see what the taskScheduler threads are doing.
See the documentation for information about how to configure the threads in the scheduler. However, if it solves it, you should really figure out what task(s) are using scheduler threads for long tasks.
Also turn on DEBUG logging to see if it provides any clues.
I have an application running on tomcat 7.0.65, and using org.apache.tomcat.jdbc.pool.DataSource
I have connection pool setup:
PoolProperties p = new PoolProperties();
p.setUrl("jdbc:oracle:thin:#....");
p.setDriverClassName("oracle.jdbc.OracleDriver");
p.setUsername("***");
p.setPassword("***");
p.setJmxEnabled(true);
p.setTestWhileIdle(false);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1 from dual");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(100);
p.setInitialSize(10);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(10);
p.setLogAbandoned(true);
p.setRemoveAbandoned(true);
p.setName("jdbc/insurancePool");
DataSource asyncDS = new DataSource(p);
Everyday when I try to run the application I get connection timed out exception for the first couple of tries. I am not sure why this is happening. Does firewall have anything to do with this?
I had the same issue with MySql everyday morning. Then I found autoReconnect parameter which can be used with JDBC URL to fix this.
For example:
MYSQL_URL=jdbc:mysql://10.*.*.0:3306/ABC?autoReconnect=true
Issue resolved, found this link helpful Firewall Issues
I changed "minIdle" to 0 and also set sqlnet.expire_time parameter in the sqlnet.ora file to 0..
Hope this helps someone else..
When standalone client and jboss server runs on the same machine, everything works fine, but when i try to run the JBoss on a VM, i can get a JNDIContext from the Server,i can do a successful lookup, but i cannot establish a connection.
The Client throwing an exception as:
Exception in thread "main" javax.jms.JMSException: Failed to create session factory
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605)
at #org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119)
...
Caused by: HornetQException[errorCode=2 message=Cannot connect to server(s). Tried with all available servers.]
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:769)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)
... 2 more
And the server End showing msg as,
JBAS011806: Channel end notification received, closing channel Channel ID 459d0f32 (inbound) of Remoting connection 00e9212a to /192.168.35.29:42179
I have seen other posts also related to this issue , but I didnt clear with the solution . So Plz help me out and forgive me If I am asking silly question since I am new in this domain.
Thanks.
You have to configure the port on the server. You probably have the server starting as localhost and you are connecting externally, in such way the JNDI can connect but not the HornetQ connector.
You certainly have a configuration error, but without knowing version, what actual message you got and configuration options I have little information to help you more beyond that.
I am building an app in extjs connecting to teradata at the back-end. It works fine locally but when deployed its giving
[Error 1277] [SQLState 08S01] Login time-out for Connection to server after 12seconds.
I am trying to increase the timeout now.
Class.forName("com.teradata.jdbc.TeraDriver");
DriverManager.setLoginTimeout(100);
Connection conn = DriverManager.getConnection(connectionString, "user", "pass");
Still I'm getting same time-out error after 12 seconds. It seems like setLoginTimeout didn't work. Where am I going wrong? Is there any other solution other than increasing time-out ?
P.S: For one server it worked fine now I changed only the server name to point to another server and I'm getting timeout.
The below link might help you.
http://forums.teradata.com/forum/connectivity/could-you-tell-me-the-reason-why-login-time-out