I met a lot network issues about connecting to RPC node of Solana, so I’m using a nginx server as a reverse proxy to bypass this problem:

location / {
        # https://serverfault.com/a/923254
        try_files /nonexistent @$http_upgrade;
}

location @ {
        proxy_pass https://api.testnet.solana.com;
        proxy_read_timeout 300s;
        proxy_send_timeout 300s;
        proxy_set_header Host "api.testnet.solana.com";
}

location @websocket {
        proxy_redirect  off;
        proxy_pass https://api.testnet.solana.com;
        proxy_http_version 1.1;
        proxy_read_timeout 300s;
        proxy_send_timeout 300s;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
}