How to access data from an AWS RDS instance using Java [duplicate] - spring

This question already has answers here:
Unable to establish connection to jdbc:mysql communication link failure
(2 answers)
Closed 1 year ago.
I have created this DB in AWS
database-1.ccbrzww0e8op.eu-west-1.rds.amazonaws.com
I am trying to connect using this URL,
jdbc:mysql://database-1.ccbrzww0e8op.eu-west-1.rds.amazonaws.com:3306/database-1
but I have this error:
[08S01]
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.
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.

I assume you are writing your own Java Connection Class. To ensure that a Spring app can communicate with an Amazon RDS instance, you need to:
Ensure that your application has a Database Driver file. This can be accomplished by using the POM file.
Ensure that your RDS instance is configured to allow public access.
Ensure that you have setup your Inbound rules to let your development machine access the database. For information about setting up security group inbound rules, see Controlling Access with Security Groups.
Once you perform these tasks, your Spring BOOT app can connect to the database and query data, as shown in this pic of a Spring BOOT app querying data from an RDS instance:

Related

Check Connection with Azure service bus using Java SDK

I am using Azure service bus with Java SDK. Currently not find any way where I can verify that connection is established or not. Is there any method or way where I can check connection is established with azure service bus?
I tried and failed to find specific way to do that.
One of the way to check whether connection is established or not is sending and receiving message from service bus. Once you have configured connection, try to send or receive message from service bus. You can check whether message is received or not using Azure portal also.
Refer this link enter link description herefor more information

AWS Neptune connection pool settings

We're using a connection pool to communicate with AWS Neptune from an AWS Lambda. Due to this, we are experiencing various connection problems. Usually, it happens after a maintenance window and requires a Neptune restart to fix it.
For example, below is an error rised in a Python Lambda after an automatic SSL certificate rollout in AWS Neptune:
Max retries exceeded with url: /endpoint/ (Caused by SSLError(SSLCertVerificationError(1,
'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1131)')))
This behavior seems to be related to the Neptune Endpoint functionality and is mentioned in the AWS Doc
A custom endpoint for a Neptune cluster represents a set of DB instances that you choose. When you connect to the endpoint, Neptune chooses one of the instances in the group to handle the connection.
When you add a DB instance to a custom endpoint or remove it from a custom endpoint, any existing connections to that DB instance remain active.
As far as a connection is still valid, it's not removed from the pool despite its not functioning anymore.
My question: How to configure the HTTP connection pool from the client-side to address this behavior? Is there a possibility to check a Neptune connection before using it?
The general best practice is to assume a connection is still alive/valid and catch/reconnect when you encounter these sorts of exceptions. Example Lambda function architecture (mainly for Gremlin, but other query languages would have similar patterns) are displayed here: https://docs.aws.amazon.com/neptune/latest/userguide/lambda-functions-examples.html

Web socket with cloud run behind a load balancer behind IAP

I have an API under cloud run. My cloud run service is behind a Load Balancer.
I'd like to open a socket connection from my front end app to my API (wss protocol).
When I use the cloud run service url it works but when I use my custom domain name I receive an error "undefined" and the connection is closed immediately. There is no log, making it very difficult for me to debug.
As I want to limit my ingress permission to Allow internal traffic and traffic from Cloud Load Balancing I can't use the cloud run service url.
On my load balancer my front end is using HTTPS protocol.
I do not understand what is blocking my socket connection.
Please ask for any details or further investigation. As I do not know where to begin my investigation I am having a hard time making a great post.
Update
If I connect using the cloud run url under allow all, it works, as I was saying. But I noticed another behavior. If I make a first connection using the cloud run url and then, try to connect using my custom domain url on the same browser. It works, whereas if I do the same operation on another browser or on a private window it fails with a 302 status code.
Update
So it appears that dis-activating IAP allow my front end to open a websocket connection to my API..
now I am trying to find a way to do the same but with IAP activated..
Thanks

Spring Boot connecting to IBM MQ Cloud

I'm trying to send a message to a IBM MQ queue from my spring boot service. I could send/receive the message from the IBM MQ installed on my laptop.
However when I replaced the configuration to connect to the IBM MQ Cloud, this is not working
Configuration is as follows:
getting the following error
Note:
I could telnet into the host & port
I tried with the following for Username & Password
With APIKey & App Name
My IBM Username & Password
It seems to be a known issue:
The connection may be broken for a number of different reasons. The 2009 return code indicates that something prevented a successful connection to the Queue Manager. The most common causes for this are the following are:
A firewall that is terminating the connection
An IOException that causes the socket to be closed
An explicit action to cause the socket to be closed by one end
The queue manager is offline
The maximum number of channels allowed by the queue manager are open
A configuration problem in the Queue Connection Factory (QCF)
Can you please try suggestions from here
Usually, the most common reason for Error Code 2009: MQRC_CONECTION_BROKEN is that your JMS client opens up multiple connections to the queue and they remain unclosed even though they're not being used. You then eventually run out of channels. You can increase the channel size to more than double of what is required.
Check your FFST log file generated by IBM MQ classes for JMS. It gives you detailed info on connections/errors:
First Failure Support Technology ( FFST ) files

Working of websocket services in clustered deployment

Lets say I have a websocket implemented in springboot. The architecture is microservice. I have deployed the service in kubernetes cluster and I have 2 running instance of the service, the socket implementation is using stomp and redis as broker.
Now the first connection is created between a client and one of the service. Does all the data flow occur through the client and the connected service? Would the other service also have a connection? Incase the current service goes down would the other service open up a connection?
Now lets say I'am sending some data back to the client which comes through a kafka topic. One of the either service could read it. If then would either of them be able to send the data back to the client?
Can someone help me understand these scenarios?
A websocket is a permanent connection. After opening it, it will be routed through kubernetes to a fixed pod. No other pod will receive the connection.
If the pod goes down, the connection is terminated.
If a new connection is created, for example by a different user, it may be routed to a different pod.
What data is transmitted, for example with kafka as source, is not relevant in this context. It could be anything.

Resources