MacOS 和 Linux 故障排除步骤

按照以下步骤识别并确认您有代理,并收集进一步故障排除所需的代理主机和端口号。

  1. 打开一个新的 Terminal 窗口。

  2. 执行以下命令可获取网络专用的代理配置详细信息。将 example.com 替换为要测试的实际主机名。

    networksetup -getsecurewebproxy "$(networksetup -listnetworkserviceorder | grep $(route get example.com | grep interface | awk -F: '{print $2}') | awk -FPort: '{print $2}' | awk -F, '{print $1}' | sed 's/^ //g')"
    
    Copy

    使用代理配置的输出示例

    Enabled: Yes
    Server: 192.168.21.12
    Port: 3128
    Authenticated Proxy Enabled: 1
    

    无代理配置的输出示例

    Enabled: No
    Server:
    Port: 0
    Authenticated Proxy Enabled: 0
    
  3. 此外,您还可以使用以下命令测试用于代理设置的常用环境变量:

    env | grep -i proxy
    
    Copy

    命令返回的输出类似于下面的内容:

    http_proxy=http://my.pro.xy:123
    HTTP_PROXY=http://my.pro.xy:123
    HTTPS_PROXY=http://my.pro.xy:123
    https_proxy=http://my.pro.xy:123
    NO_PROXY=localhost,.company.com,.amazonaws.com
    
    • 找到代理:根据这些环境变量设置,可以收集到 进一步测试 所需的代理主机和端口。

    • 未找到代理:如果输出为空,则很可能没有为代理配置设置环境变量,需要 进一步测试

    • NO_PROXY 定义了客户端无需通过代理服务器即可直接连接的主机。

如果您有代理

您可以确定出现连接问题的具体 URL。虽然测试 Snowflake 允许列表中列出的所有 URLs 都很有益处,但您可能希望将重点放在直接导致您的设置出现问题的 URL 上。

export http_proxy=http://<PROXY_HOST:PROXY_PORT> && export HTTP_PROXY=$http_proxy && export HTTPS_PROXY=$http_proxy && export https_proxy=$http_proxy

curl -v https://URL 2>&1 | tee | grep "Trying\|Connected\|Establish\|CONNECT\|subject\|issuer\|HTTP\|curl"
Copy

或者,也可以直接将代理设置传入 :code:`curl`(无需先设置环境变量),如图所示:

  • 未进行身份验证的的代理

    curl --proxy “<PROTOCOL>://<HOST>:<PORT>” ..rest of the arguments..
    
    Copy
  • 已进行身份验证的代理

    curl --proxy “<PROTOCOL>://<HOST>:<PORT>” --proxy-user user:pass ..rest of the arguments..
    
    Copy

Terminal 中,请运行以下命令。使用导致问题的 URL 更新命令。将 <URL> with the problematic URL. Additionally, replace <PROXY_URL> 替换为您的代理信息。

export http_proxy=http://<PROXY_URL> && export HTTP_PROXY=$http_proxy && export HTTPS_PROXY=$http_proxy && export https_proxy=$http_proxy

curl -v https://<URL> 2>&1 | tee | grep "Trying\|Connected\|Establish\|CONNECT\|subject\|issuer\|HTTP\|curl"
Copy

这些命令将配置您的环境,使其使用代理处理 HTTP 和HTTPS 请求,并尝试连接到指定的 Snowflake URL。它还会输出有关连接尝试的详细信息,包括任何成功的连接或遇到的错误。

成功连接示例输出:

➜  curl -v https://<account>.snowflakecomputing.cn 2>&1 | tee | grep "Trying\|Connected\|Establish\|CONNECT\|subject\|issuer\|HTTP\|curl"
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying <IP ADDRESS>...
* Connected to <IP ADDRESS> (<IP ADDRESS>) port <PORT> (#0)
* Establish HTTP proxy tunnel to <account>.snowflakecomputing.cn:443
> CONNECT <account>.snowflakecomputing.cn:443 HTTP/1.1
> User-Agent: curl/7.79.1
< HTTP/1.1 200 Connection established
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
*  subject: CN=*.us-east-1.snowflakecomputing.cn
*  subjectAltName: host "<account>.snowflakecomputing.cn" matched cert's "*.us-east-1.snowflakecomputing.cn"
*  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
> GET / HTTP/1.1
> User-Agent: curl/7.79.1
< HTTP/1.1 302 Found

输出分析:

  • “连接到......”表示成功连接到代理 (<IP ADDRESS>) 并建立了到 Snowflake 的 HTTP 隧道。

  • HTTP 状态码(如 HTTP/1.1 200 Connection established)后跟 HTTP/1.1 302 Found,表明登录页面成功。

完成这些步骤后,继续 执行后续行动

如果您没有代理

Terminal 中,运行以下命令,确保更新命令中的 URL,以匹配您正在测试的 Snowflake URL。

curl -v https://<URL> 2>&1 | tee | grep "Trying\|Connected\|Establish\|CONNECT\|subject\|issuer\|HTTP\|curl"
Copy

成功连接示例输出:

➜  curl -v https://<account>.snowflakecomputing.cn 2>&1 | tee | grep "Trying\|Connected\|Establish\|CONNECT\|subject\|issuer\|HTTP\|curl"

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 52.22.29.117:443...
* Connected to <account>.snowflakecomputing.cn (52.22.29.117) port 443 (#0)
*  subject: CN=*.us-east-1.snowflakecomputing.cn
*  subjectAltName: host "<account>.snowflakecomputing.cn" matched cert's "*.us-east-1.snowflakecomputing.cn"
*  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0> GET / HTTP/1.1
< HTTP/1.1 302 Found

此输出显示连接成功,表明您的系统可以连接到 Snowflake 服务器并与之通信。

连接失败示例:

➜  curl -v https://<account>.snowflakecomputing.cn 2>&1 | tee | grep "Trying\|Connected\|Establish\|CONNECT\|subject\|issuer\|HTTP\|curl"
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 52.22.29.117:443...
*   Trying 3.222.247.13:443...
*   Trying 54.81.51.170:443...
curl: (7) Failed to connect to <account>.us-east-1.snowflakecomputing.cn port 443 after 3139 ms: Connection refused

完成这些步骤后,继续 执行后续行动

语言: 中文