用于连接到 Snowflake 数据的 HAProxy 设置
HAProxy settings for connecting to Snowflake Data
我一直在尝试通过代理使用 ODBC 驱动程序连接到 Snowflake,但到目前为止还无法连接。我正在使用 HAProxy 来执行此操作。
这是来自 odbc.ini
,我在其中配置了我的 DSN:
[ODBC Data Sources]
SnowflakeDSII = Snowflake
[SnowflakeDSII]
Server = <account>.<region>.snowflakecomputing.com
Port = 443
UID = <username>
PWD = <password>
Schema =
Warehouse =
Driver = /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib
Description = Snowflake DSII
Locale = en-US
Tracing = 0
proxy = http://127.0.0.1:8000
这是我的 HAProxy 配置:
global
log stdout format raw local0 info
defaults
log global
# timeouts
timeout connect 3600s
timeout client 3600s
timeout server 3600s
maxconn 4000
frontend snowflake_proxy
mode tcp
option tcplog
bind 0.0.0.0:8000
default_backend snowflake
backend snowflake
mode tcp
option tcp-check
server server0 <account>.<region>.snowflakecomputing.com:443 check
在 运行 iodbctest
,我看到了这个错误:
OOB curl_easy_perform() failed: Failure when receiving data from the peer
1: SQLDriverConnect = [Snowflake][Snowflake] (4)
REST request for URL https://<account>.<region>.snowflakecomputing.com:443/session/v1/login-request?requestId=0fe536ed-4d6c-4858-b468-52a6757248a7&request_guid=5477913c-989a-4da3-bbbc-b62a68391749 failed: CURLerror (curl_easy_perform() failed) - code=56 msg='Failure when receiving data from the peer' osCode=36 osMsg='Operation now in progress'.
(4) SQLSTATE=HY000
1: ODBC_Connect = [Snowflake][Snowflake] (4)
REST request for URL https://<account>.<region>.snowflakecomputing.com:443/session/v1/login-request?requestId=0fe536ed-4d6c-4858-b468-52a6757248a7&request_guid=5477913c-989a-4da3-bbbc-b62a68391749 failed: CURLerror (curl_easy_perform() failed) - code=56 msg='Failure when receiving data from the peer' osCode=36 osMsg='Operation now in progress'.
(4) SQLSTATE=HY000
我还尝试将 HAProxy 配置为充当简单的 HTTP 代理。这是我的 HAProxy 配置:
global
log stdout format raw local0 info
defaults
log global
# timeouts
timeout connect 3600s
timeout client 3600s
timeout server 3600s
maxconn 4000
frontend snowflake_proxy
mode http
option httplog
bind 0.0.0.0:8000
default_backend snowflake
backend snowflake
mode http
option http-server-close
option http_proxy
使用上面的 HAProxy 配置,我看到了这个错误:
OOB curl_easy_perform() failed: Failure when receiving data from the peer
1: SQLDriverConnect = [Snowflake][Snowflake] (4)
REST request for URL https://<account>.<region>.snowflakecomputing.com:443/session/v1/login-request?requestId=01ccf8d9-895b-47d1-9102-41f7524ec436&request_guid=773e75b3-9137-4862-a5e1-3bf49e076a1d failed: CURLerror (curl_easy_perform() failed) - code=56 msg='Failure when receiving data from the peer'.
(4) SQLSTATE=HY000
1: ODBC_Connect = [Snowflake][Snowflake] (4)
REST request for URL https://<account>.<region>.snowflakecomputing.com:443/session/v1/login-request?requestId=01ccf8d9-895b-47d1-9102-41f7524ec436&request_guid=773e75b3-9137-4862-a5e1-3bf49e076a1d failed: CURLerror (curl_easy_perform() failed) - code=56 msg='Failure when receiving data from the peer'.
(4) SQLSTATE=HY000
来自 HAProxy 的日志:
127.0.0.1:64824 [31/Jan/2020:13:28:19.888] snowflake_proxy snowflake/<NOSRV> -1/-1/-1/-1/0 400 211 - - PR-- 1/1/0/0/3 0/0 "CONNECT <account>.<region>.snowflakecomputing.com:443 HTTP/1.1"
127.0.0.1:64825 [31/Jan/2020:13:28:21.890] snowflake_proxy snowflake/<NOSRV> -1/-1/-1/-1/0 400 211 - - PR-- 1/1/0/0/3 0/0 "CONNECT <account>.<region>.snowflakecomputing.com:443 HTTP/1.1"
127.0.0.1:64826 [31/Jan/2020:13:28:25.894] snowflake_proxy snowflake/<NOSRV> -1/-1/-1/-1/0 400 211 - - PR-- 1/1/0/0/3 0/0 "CONNECT <account>.<region>.snowflakecomputing.com:443 HTTP/1.1"
127.0.0.1:64829 [31/Jan/2020:13:28:33.898] snowflake_proxy snowflake/<NOSRV> -1/-1/-1/-1/0 400 211 - - PR-- 1/1/0/0/3 0/0 "CONNECT <account>.<region>.snowflakecomputing.com:443 HTTP/1.1"
127.0.0.1:64830 [31/Jan/2020:13:28:33.903] snowflake_proxy snowflake/<NOSRV> -1/-1/-1/-1/0 400 211 - - PR-- 1/1/0/0/3 0/0 "CONNECT sfctest.client-telemetry.snowflakecomputing.com:443 HTTP/1.1"
有没有人有幸做过类似的事情?您可以分享您的 HAProxy 配置的相关部分吗?
由于需要在代理上配置 SSL 直通,HAProxy 可能很难配置并用作 Snowflake 的 ODBC 驱动程序的转发代理。
原因在this SO answer中说明:
I captured packets , using proxy to visit a https website , curl will start a HTTP CONNECT method to establish a tunnel. The tunnel should be between curl client and proxy, but TCP proxy will delivery all messages to web server, so web server will reset the connection.
A forward proxy should not just delivery messages between client and web server.It should understand the HTTP CONNECT method
HAProxy 在执行 SSL 直通时充当 TCP 代理,因此不解析底层消息。然而,它需要先建立隧道,然后再这样做,这需要响应 HTTP CONNECT
方法。
我一直在尝试通过代理使用 ODBC 驱动程序连接到 Snowflake,但到目前为止还无法连接。我正在使用 HAProxy 来执行此操作。
这是来自 odbc.ini
,我在其中配置了我的 DSN:
[ODBC Data Sources]
SnowflakeDSII = Snowflake
[SnowflakeDSII]
Server = <account>.<region>.snowflakecomputing.com
Port = 443
UID = <username>
PWD = <password>
Schema =
Warehouse =
Driver = /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib
Description = Snowflake DSII
Locale = en-US
Tracing = 0
proxy = http://127.0.0.1:8000
这是我的 HAProxy 配置:
global
log stdout format raw local0 info
defaults
log global
# timeouts
timeout connect 3600s
timeout client 3600s
timeout server 3600s
maxconn 4000
frontend snowflake_proxy
mode tcp
option tcplog
bind 0.0.0.0:8000
default_backend snowflake
backend snowflake
mode tcp
option tcp-check
server server0 <account>.<region>.snowflakecomputing.com:443 check
在 运行 iodbctest
,我看到了这个错误:
OOB curl_easy_perform() failed: Failure when receiving data from the peer
1: SQLDriverConnect = [Snowflake][Snowflake] (4)
REST request for URL https://<account>.<region>.snowflakecomputing.com:443/session/v1/login-request?requestId=0fe536ed-4d6c-4858-b468-52a6757248a7&request_guid=5477913c-989a-4da3-bbbc-b62a68391749 failed: CURLerror (curl_easy_perform() failed) - code=56 msg='Failure when receiving data from the peer' osCode=36 osMsg='Operation now in progress'.
(4) SQLSTATE=HY000
1: ODBC_Connect = [Snowflake][Snowflake] (4)
REST request for URL https://<account>.<region>.snowflakecomputing.com:443/session/v1/login-request?requestId=0fe536ed-4d6c-4858-b468-52a6757248a7&request_guid=5477913c-989a-4da3-bbbc-b62a68391749 failed: CURLerror (curl_easy_perform() failed) - code=56 msg='Failure when receiving data from the peer' osCode=36 osMsg='Operation now in progress'.
(4) SQLSTATE=HY000
我还尝试将 HAProxy 配置为充当简单的 HTTP 代理。这是我的 HAProxy 配置:
global
log stdout format raw local0 info
defaults
log global
# timeouts
timeout connect 3600s
timeout client 3600s
timeout server 3600s
maxconn 4000
frontend snowflake_proxy
mode http
option httplog
bind 0.0.0.0:8000
default_backend snowflake
backend snowflake
mode http
option http-server-close
option http_proxy
使用上面的 HAProxy 配置,我看到了这个错误:
OOB curl_easy_perform() failed: Failure when receiving data from the peer
1: SQLDriverConnect = [Snowflake][Snowflake] (4)
REST request for URL https://<account>.<region>.snowflakecomputing.com:443/session/v1/login-request?requestId=01ccf8d9-895b-47d1-9102-41f7524ec436&request_guid=773e75b3-9137-4862-a5e1-3bf49e076a1d failed: CURLerror (curl_easy_perform() failed) - code=56 msg='Failure when receiving data from the peer'.
(4) SQLSTATE=HY000
1: ODBC_Connect = [Snowflake][Snowflake] (4)
REST request for URL https://<account>.<region>.snowflakecomputing.com:443/session/v1/login-request?requestId=01ccf8d9-895b-47d1-9102-41f7524ec436&request_guid=773e75b3-9137-4862-a5e1-3bf49e076a1d failed: CURLerror (curl_easy_perform() failed) - code=56 msg='Failure when receiving data from the peer'.
(4) SQLSTATE=HY000
来自 HAProxy 的日志:
127.0.0.1:64824 [31/Jan/2020:13:28:19.888] snowflake_proxy snowflake/<NOSRV> -1/-1/-1/-1/0 400 211 - - PR-- 1/1/0/0/3 0/0 "CONNECT <account>.<region>.snowflakecomputing.com:443 HTTP/1.1"
127.0.0.1:64825 [31/Jan/2020:13:28:21.890] snowflake_proxy snowflake/<NOSRV> -1/-1/-1/-1/0 400 211 - - PR-- 1/1/0/0/3 0/0 "CONNECT <account>.<region>.snowflakecomputing.com:443 HTTP/1.1"
127.0.0.1:64826 [31/Jan/2020:13:28:25.894] snowflake_proxy snowflake/<NOSRV> -1/-1/-1/-1/0 400 211 - - PR-- 1/1/0/0/3 0/0 "CONNECT <account>.<region>.snowflakecomputing.com:443 HTTP/1.1"
127.0.0.1:64829 [31/Jan/2020:13:28:33.898] snowflake_proxy snowflake/<NOSRV> -1/-1/-1/-1/0 400 211 - - PR-- 1/1/0/0/3 0/0 "CONNECT <account>.<region>.snowflakecomputing.com:443 HTTP/1.1"
127.0.0.1:64830 [31/Jan/2020:13:28:33.903] snowflake_proxy snowflake/<NOSRV> -1/-1/-1/-1/0 400 211 - - PR-- 1/1/0/0/3 0/0 "CONNECT sfctest.client-telemetry.snowflakecomputing.com:443 HTTP/1.1"
有没有人有幸做过类似的事情?您可以分享您的 HAProxy 配置的相关部分吗?
由于需要在代理上配置 SSL 直通,HAProxy 可能很难配置并用作 Snowflake 的 ODBC 驱动程序的转发代理。
原因在this SO answer中说明:
I captured packets , using proxy to visit a https website , curl will start a HTTP CONNECT method to establish a tunnel. The tunnel should be between curl client and proxy, but TCP proxy will delivery all messages to web server, so web server will reset the connection.
A forward proxy should not just delivery messages between client and web server.It should understand the HTTP CONNECT method
HAProxy 在执行 SSL 直通时充当 TCP 代理,因此不解析底层消息。然而,它需要先建立隧道,然后再这样做,这需要响应 HTTP CONNECT
方法。