最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin6浏览0评论

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.`

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论