could not connect aws elasticache redis from .net app - amazon-web-services

I am connecting .NET core app to AWS ElastiCache Redis.
The AWS Elasticache Redis is running and port 6329 is open on security group. The client code is using StackExchange.Redis:
var redis = ConnectionMultiplexer.Connect("redis-1.xxxx.0001.use1.cache.amazonaws.com:6379");
//var redis = ConnectionMultiplexer.Connect("localhost"); //working
IDatabase db = redis.GetDatabase();
string value = "abcdefg";
db.StringSet("mykey", value);
string value2 = db.StringGet("mykey");
Console.WriteLine(value2); // writes: "abcdefg"
Console.ReadLine();
Exception is:
It was not possible to connect to the redis server(s). UnableToConnect
on redis-1.xxx.0001.use1.cache.amazonaws.com:6379/Interactive,
Initializing/NotStarted, last: NONE, origin: BeginConnectAsync,
outstanding: 0, last-read: 5s ago, last-write: 5s ago, keep-alive:
60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat:
never, global: 0s ago, v: 2.0.601.3402
Added to ,abortConnect=false to the endpoint, I am able to connect.
Now the error is at StringSet
StackExchange.Redis.RedisConnectionException: 'No connection is
available to service this operation: SET mykey; UnableToConnect ...
The .NET code is working fine with my local Redis service so looks like something incorrect with my AWS setup.
Successfully ssh to my EC2-instance and redis-cli to my AWS redis service:
Any idea please?
NOTE: AWS Elasticache Redis is NOT available for public access as default.
https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/accessing-elasticache.html#access-from-outside-aws
Can you connect to Amazon ElastiŠ”ache Redis outside of Amazon?

Question: "...port 6329 is open on security group.." Dont you mean 6379?
Even that, i think i cn have an issue on the "default" subnet groups.
Does the VPC_Subnet (in that group) where the AWS ElastiCache Redis is, has a Routing Table with access to the Internet Gateway?
If not, you need to attache the InternetGteway to the Route Table and than use that Route Table on the Subnet that you want.
It should be like the pick:
Internet GW

Related

TCP Connection to Google SQL gives OperationalError (from containerized app in GKE)

I have a Flask & SQLAlchemy service containerized and deployed to Google Kubernetes Engine and I establish a TCP connection to my database in Google SQL. When developing locally, the connection is successful because I've added my computer's IP address to the "authorised networks" for my database instance in Google SQL. However, when I deploy my service to a cluster in GKE, the TCP connection to the db gives OperationalError.
I believe this error is mainly because the IP address of my cluster is not added to "authorised networks" (to verify I deleted my computer's IP from authorised networks and tested the connection locally and got the same OperationalError). I've authorized both the endpoint IP of my cluster, pod address range (see below image) and also the IP exposed to the internet for my service, however, both didn't seem to work. In order authorize my GKE cluster to connect the db in Google SQL, which IP should I add to the "authorized networks"?
Here's how I build the connection URL:
class Config(object):
if os.environ.get('ENVIRONMENT') == 'production':
log.debug("You're using the remote db URL!!!")
db_user = os.environ.get("DB_USER")
db_pass = os.environ.get("DB_PASS")
db_name = os.environ.get("DB_NAME")
db_hostname = os.environ.get("DB_HOST")
db_port = os.environ.get("DB_PORT")
SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{db_user}:{db_pass}#{db_hostname}:{db_port}/{db_name}"
Rather than adding the entire node network to Authorized Networks, I'd suggest using the Cloud SQL proxy to authorize your connections. There is a how-to guide here: https://cloud.google.com/sql/docs/mysql/connect-kubernetes-engine

Unable to Connect AWS RDS from SQL Developer

I just need help here,
I'm just getting started into AWS RDS, I have web application and I have deployed into AWS Through AWS EBS
and now I wanted to connect my DB, for that I attached RDS to my application in beanstalk. When testing the connection, I am Getting this error
This is my ENDPOINT:
Here are my RDS DB Configuration:
and SID is:
please help me sort this, I got stuck here from 2 days.
Thank You.... :)
Please, in your connection setup in SQL Developer, in the Hostname field, just remove the literal :3306 at the end of your hostname string: this value is in fact the port in which the database is listening.
In order to complete your connection setup, enter the value 3306 in the Port field instead of the 1521 you indicated in your image.

AWS Lambda Websocket return task timed out after 6 seconds, but works locally

I have written a Lambda function as Websocket and API Gateway using Serverless and Redis. Also using AWS-CLI to deploy project on AWS S3. I am receiving:
Task timed out after 6.01 seconds
Increasing the timeout or request size gives me the same message but with higher amount of timeout seconds. The strange thing is that it works locally, but not when it's deployed to AWS. Code should work. I think something is missing in AWS configurations.
I created separate VPC with 3 subnets: 2 private and 1 public. I created also NAT using public subnet Internet Network. I added route to 0.0.0.0/0. I maintained IAM Role to permit API execution etc.
It happens here:
return this.ws
.postToConnection({
ConnectionId: connId,
Data: payloadStr
})
Where ws is
this.ws = new ApiGatewayManagementApi({
apiVersion: '2018-11-29',
endpoint: endpoint
});
I checked connId and it's not null.
I update with schema how my network looks like:
I've just finally fixed this issue. My mistake was that I attached Nat gateway to private subnet instead of public, so this diagram is wrong.

How to permit Google Cloud Data Fusion to connect to an AWS RDS MySQL database?

I'm getting an error in configuring a database connection in a Google Cloud Data Fusion Pipeline.
"Encountered SQL error while getting query schema: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."
We can't connect outside of the company building as the company IP's are whitelisted in AWS security settings. I can query easily using mysql workbench inside the company so, I'm guessing I need to add some IPs to our AWS security groups to provide Data Fusion permissions? I can't find a guideline on this. Where can I find the ip's required to provide in AWS? (Assuming that might fix it)
I've added a mysql plugin artefact using 'mysql-connector-java-8.0.17.jar', which is referred to by plugin name 'mysql-connector-java'.
Do VPN between your GCP VPC and your AWS VPC where your RDS is residing
https://cloud.google.com/solutions/using-gcp-apis-from-an-external-network
https://cloud.google.com/solutions/automated-network-deployment-multicloud
Simple way
Create Haproxy with public IP
Data Fusion --> VM Haproxy Public IP --> AWS RDS Private IP

Neptune throwing "Host did not respond in a timely fashion" when trying to connect from private EC2

I have created a neptune instance and per the documentation here...
I create the following yaml...
hosts: [xxx.xxx.us-east-2.neptune.amazonaws.com]
port: 8182
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}
And when I try to connect everything seems to work I see...
==>All scripts will now be sent to Gremlin Server - [xx.xx.us-east-2.neptune.amazonaws.com/172.xx.x.xxx:8182] - type
':remote console' to return to local mode
What am I missing why is the query failing?
Have you enabled IAM authentication on your instance?
If yes, you will have to perform some additional steps to connect to the DB.
If no, double check the following:
EC2 instance is in the same VPC as the cluster.
Check the inbound settings for security group attached to the cluster and outbound setting for your EC2 instance.
If it still doesn't connect, I would suggest you to contact AWS Support.
Are you trying to connect from your pc or ec2 instance ?
I think that Neptune is not publicly accessibly
create ec2 instance in the same VPC and try to connect from it