go-redis/v8 connection pool timeout - connection

** connection pool **
client := redis.NewClient(&redis.Options{
Addr: "Amazon ElastiCache for Redis ",
Password: "", // no password set
DB: 0, // use default DB
IdleCheckFrequency: 15*time.Second,
IdleTimeout:60*time.Second,
MinIdleConns: 15,
MaxConnAge: 60*time.Second,
})
var RedisCtx = context.Background()
_, err:=client.Exists(RedisCtx,key).Result()
if err!=nil{
//Random reminder connection pool timeout. why?
logs.Warning("exists redis error",err)
}
The connection pool will occasionally appear in use “connection pool timeout”
redis use "Amazon ElastiCache for Redis "
thanks!!

If TLS on the ElastiCache is enabled you have to add TLSConfig into your client option and choose the TLS version or just leave it with an empty struct just be fine, Please let me know if it works or not

Related

Can we change connection dynamicly to Elasticsearch server on Rails App at run time

I have 2 elasticsearch servers. On my rails app, can I change connection to the Elasticsearch servers at run time?
For example,
- If user 1 log in the app, it should connect to elasticsearch server 1
- If user 2 log in the app, it should connect to elasticsearch server 2
Thanks
You can use randomize_hosts when creating connection
args = {
hosts: "https://host1.local:9091,https://host2.local:9091",
adapter: :httpclient,
logger: (Rails.env.development? || Rails.env.test?) ? Rails.logger : nil,
reload_on_failure: false,
randomize_hosts: true,
request_timeout: 5
}
client = Elasticsearch::Client.new(args)
Randomize hosts doc
Here you can read about a different host selection strategy than round robin. You could implement your own ideas.

How to establish connection to the neo4j graph database in javascript with js2neo driver

I get this error when i try to use the connection
WebSocket connection to 'ws://bolt//localhost:7687' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED
Downloaded neo4j desktop
started the browser and added a local graph database.
Downloaded the js2neo driver
<script src="js/js2neo.min.js"></script>
connected to the database as per http://js2neo.org/
var cx = js2neo.open({ host: "bolt://localhost", user: "neo4j",
password: "1234567890!" })
test the content of the database
cx.run("MATCH (n) RETURN *", { onRecord: console.log })
Your host configuration is not good (it's host not url).
So instead of
var cx = js2neo.open({ host: "bolt://localhost", user: "neo4j",
password: "1234567890!" })
do this :
var cx = js2neo.open({ host: "localhost", user: "neo4j",
password: "1234567890!" })

AWS elasticsearch service throws Faraday::ConnectionFailed: Failed to open TCP connection to https:80 (getaddrinfo: Name or service not known)

I am currently trying to configure AWS’ elasticsearch service in my Rails v 5.1.4 application. I am using elasticsearch-rails 6.0.0. The issue I am currently getting I believe is with how my elasticsearch client is being set up in my initializer. One restriction I have is I can’t use the faraday_middleware-aws-signers-v4 gem to help communication between my AWS elastisearch instance and my app. I am attempting to do this with just aws-sdk-rails 1.0.1. Since this server is in the same security group as the elasticsearch instance I am assuming I don't need to pass in credentials.
Here is the my error:
Faraday::ConnectionFailed: Failed to open TCP connection to https:80 (getaddrinfo: Name or service not known)
from /usr/local/lib/ruby/2.4.0/net/http.rb:906:in `rescue in block in connect'`
Here is my initializers/elasticsearch.rb:
config = {
hosts: {host: 'https://search-epl-elasticsearch-xxxxxxxxxxxxxxxxxx.us-east-2.es.amazonaws.com', port: '80'},
transport_options: {
request: { timeout: 5 }
}
}
Elasticsearch::Model.client = Elasticsearch::Client.new(config)
I realise it's months later, but it appears you're configuring elasticsearch with an https url and telling it to use port 80 instead of 443. Try this instead:
config = {
url: 'https://search-epl-elasticsearch-xxxxxxxxxxxxxxxxxx.us-east-2.es.amazonaws.com',
transport_options: {
request: { timeout: 5 }
}
}
Elasticsearch::Model.client = Elasticsearch::Client.new(config)

Exception when connecting to Database through Dart

I was trying to connect to MySQL database in Flutter application using sqljocky5 using the below code using dart language
void getInfo () async {
var pool = new ConnectionPool(
host: 'localhost',
port: 3305,
user: 'root',
password: 'mysql',
db: 'smartlender',
max :5
);
print('test');
var results = await pool.query('SELECT employee.firstName FROM smartlender.employee;'); // exception is thrown here
results.forEach((row){ // for each loop to add data to the list created above
names.add(row[0].toString());
});
Then I received this exception:
I have working connection to MySQL database and the query is exiting without an error .
I appreciate a lot if someone could resolve this issue .
Isn't it default Mysql port number 3306?

Can't connect java client to Marklogic database

I've just installed a MarkLogic nosql database out of the box on a windows machine.
I wrote a simple javaclient to put data in to the database but I get this error:
org.apache.http.conn.HttpHostConnectException: Connection to http://my.caci.local:8003 refused
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:158)
The Marklogic database is started. This is the code :
DatabaseClient client = DatabaseClientFactory.newClient("localhost", 8003, "admin", "admin", Authentication.DIGEST);
XMLDocumentManager docMgr = client.newXMLDocumentManager(); BinaryDocumentManager binMgr = client.newBinaryDocumentManager();
DOMHandle handle = new DOMHandle(); for (int i = 0; i < AANT_PERSONEN; i++) {
Document document = createDocument(i);
String docId = "/zaak/" + 20;
handle.set(document);
docMgr.write(docId, handle); }
....
The Marklogic console reports the following ports to be active on my.caci.local:
Default :: Admin : 8001 [HTTP]
Default :: App-Services : 8000 [HTTP]
Default :: HealthCheck : 7997 [HTTP]
Default :: Manage : 8002 [HTTP]
I'm new to marklogic and this is my question:
- what port should I use to connect to from my java client?
In agreement with MystyxMac, I notice the console does not report a REST server on 8003.
Here's the documentation for setting up a REST server:
http://docs.marklogic.com/guide/rest-dev/intro#id_97899
You should also add users for the rest-reader, rest-writer, and rest-admin roles.
Hoping that helps,
Erik Hennum
For testing purposes you can simply switch the port you are using to 8000.
From the documentation:
When you install MarkLogic Server, a pre-configured REST API instance
is available on port 8000. This instance uses the Documents database
as the content database and the Modules database as the modules
database.
The instance on port 8000 is convenient for getting started, but you
will usually create a dedicated instance for production purposes.
http://docs.marklogic.com/guide/rest-dev/service#id_15309

Resources