First SSL Handshake Takes 45-60 Seconds on Initial API Call (Nginx Reverse Proxy, Tomcat, RTK Query, React Native, Let's

We are facing an issue where the first API call in our React Native app takes 45-60 seconds due to a sl

We are facing an issue where the first API call in our React Native app takes 45-60 seconds due to a slow SSL handshake. After the initial request, subsequent API calls work fine.

Our setup is as follows:

  • Backend: Tomcat (Serving APIs)
  • Reverse Proxy: Nginx (Handles SSL termination)
  • Mobile App: React Native (Using Redux Toolkit Query for API calls)
  • SSL Certificate: Let's Encrypt (Installed on Nginx)

Issue:

Whenever a user opens the app for the first time, the initial API request triggers an SSL handshake delay of 45-60 seconds. This happens only on the first request, and subsequent requests are fast.

What We Have Tried:

  • Enabled SSL Session Resumption in Nginx (ssl_session_cache)

    ssl_session_cache shared:SSL:50m;
    ssl_session_timeout 4h;
    ssl_session_tickets on;
    keepalive_timeout 75s;
    keepalive_requests 100;
    

    Result: No major improvement.

  • Preloaded API Calls in React Native (useEffect)

    useEffect(() => {
      triggerGetData();  // Preload API call to warm up SSL connection
    }, []);
    

    Result: Helped slightly, but still slow for first-time users.

  • Enabled HTTP/2 in Nginx

    listen 443 ssl http2;
    

    Result: No noticeable improvement.

  • Checked SSL Handshake Timing Using OpenSSL

    openssl s_client -connect yourdomain:443 -showcerts -time
    

    Result: Handshake took ~15 sec on first request but was fast on retries.`

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1741211544a4326874.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信