What Should I Do If an Error Is Returned When I Use the Jedis Connection Pool?
The error message that will possibly be displayed when you use the Jedis connection pool JedisPool is as follows:
redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
If this error message is displayed, check whether your instance is running properly. If it is running properly, perform the following checks:
- Check the network.
- Check the IP address configurations.
Check whether the IP address configured on the Jedis client is the same as the subnet address configured for your DCS instance. If public access is enabled for your instance, check whether the IP address configured on the Jedis client is the same as the EIP bound to your instance. If they are inconsistent, modify the IP address configuration and then try again.
- Test the network.
Use the ping command and telnet on the client to test the network.
- If the network cannot be pinged:
- For intra-VPC access, ensure that the client and your DCS instance are in the same VPC, and security group rules or whitelist has been correctly configured.
- For public access with SSL, ensure that you have configured the security group of your DCS instance, allowing access through port 36379 as instructed in Security Group Configurations.
- For public access without SSL, ensure that you have configured the security group of your DCS instance, allowing access through port 6379 as instructed in Security Group Configurations.
- If the IP address can be pinged but telnet failed, restart your instance. If the problem persists after the restart, contact technical support.
- If the network cannot be pinged:
- Check the IP address configurations.
- Check the number of connections.
Check whether the number of established network connections exceeds the upper limit configured for JedisPool. If the number of established connections approaches the configured upper limit, restart the DCS service and check whether the problem persists. If the number of established connections is far below the upper limit, continue with the following checks.
In Unix or Linux, run the following command to query the number of established network connections:
netstat -an | grep 6379 | grep ESTABLISHED | wc -l
In Windows, run the following command to query the number of established network connections:
netstat -an | find "6379" | find "ESTABLISHED" /C
- Check the JedisPool code.
If the number of established connections approaches the upper limit, determine whether the problem is caused by service concurrency or incorrect usage of JedisPool.
When using JedisPool, you must call jedisPool.returnResource() or jedis.close() (recommended) to release the resources after you call jedisPool.getResource().
- Check the number of TIME_WAIT connections.
Run the ss -s command to check whether there are too many TIME_WAIT connections on the client.
If there are too many TIME_WAIT connections, modify the kernel parameters by running the /etc/sysctl.conf command as follows:
##Uses cookies to prevent some SYN flood attacks when the SYN waiting queue overflows. net.ipv4.tcp_syncookies = 1 ##Reuses TIME_WAIT sockets for new TCP connections. net.ipv4.tcp_tw_reuse = 1 ##Enables quick reclamation of TIME_WAIT sockets in TCP connections. net.ipv4.tcp_tw_recycle = 1 ##Modifies the default timeout time of the system. net.ipv4.tcp_fin_timeout = 30
After the modification, run the /sbin/sysctl -p command for the modification to take effect.
- If the problem persists after you perform the preceding checks, perform the following steps.
Capture packets and send packet files along with the time and description of the exception to technical support for analysis.
Run the following command to capture packets:
tcpdump -i eth0 tcp and port 6379 -n -nn -s 74 -w dump.pcap
In Windows, you can also install the Wireshark tool to capture packets.
For public access, change the port number to 36379.
Replace the NIC name to the actual one.
Client and Network Connection FAQs
- Does DCS Support Public Access?
- Troubleshooting Redis Connection Failures
- Does DCS Support Cross-VPC Access?
- Will I Be Charged for the EIP Used for Public Access to a DCS Redis Instance?
- Why Is "(error) NOAUTH Authentication required" Displayed When I Access a DCS Redis Instance?
- What Should I Do If Access to DCS Fails After Server Disconnects?
- Why Do Requests Sometimes Time Out in Clients?
- What Should I Do If an Error Is Returned When I Use the Jedis Connection Pool?
- How Do I Access a DCS Redis Instance Through Redis Desktop Manager?
- What If "ERR Unsupported CONFIG subcommand" is Displayed in SpringCloud?
- What Can I Do If I Fail to Access a DCS Instance Using Its Domain Name Address?
- Can I Access DCS Instances in a Local Environment?
- What Should Be Noted When Using Redis for Pub/Sub?
- Why Is Public Access of My DCS Redis Instance Unintentionally Disabled?
- What Can I Do If Error "Cannot assign requested address" Is Returned When I Access Redis Using connect?
- Connection Pool Selection and Recommended Jedis Parameter Settings
- What Can I Do If a Lettuce 6.x Client Is Incompatible with My DCS Instance?
- Should I Use a Domain Name or an IP Address to Connect to a DCS Redis Instance?
- Is the Read-only Address of a Master/Standby Instance Connected to the Master or Standby Node?
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbotmore