Heroku需要Tiny_tds/freetds解决方案

pes8fvy9  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(118)

目前有没有办法在Heroku的最新堆栈上安装tiny_tds到rails 7应用程序上?所有的解决方法似乎都很旧/无法操作。我正在尝试在Heroku上安装Azure MSSQL插件并运行。
我已经能够安装buildpack了,但是每次我使用TDS(甚至通过heroku rails控制台进行连接)时,我都会收到超时错误。如果我在本地运行完全相同的命令,它就会工作。

client = TinyTds::Client.new host: '<host>.database.windows.net', database: "<database>",username: "<username>@<host>.database.windows.net",password: "<password>", port: 1433, azure: tr
ue, tds_version: 7.4, timeout: 300, login_timeout: 300

Adaptive Server connection timed out ([server].database.windows.net:1433)
此外,我还可以在heroku bash提示符下成功运行以下命令:

~ $ nslookup
> <host>.database.windows.net
Server:     <server ip address>
Address:    <server ip address>#53
Non-authoritative answer:
<host>.database.windows.net canonical name = <other host name>.eastus.database.windows.net.
<other host name>.eastus.database.windows.net   canonical name = <other host name>.trafficmanager.net.
<other host name>.trafficmanager.net    canonical name = <another host name>.control.database.windows.net.
Name:   <another host name>.control.database.windows.net
Address: <ip address>

~ $ nc -zv <host>.database.windows.net 1433
Connection to <host>.database.windows.net (<ip address>) 1433 port [tcp/ms-sql-s] succeeded!

我也尝试过在heroku上使用freetds(这是tinytds所必需的)并得到超时,所以我相信错误可以追溯到freetds与heroku或heroku buildpack的交互,我已经尝试了各种版本(https://github.com/rails-sqlserver/heroku-buildpack-freetds):
在我的本地MacBook上,我可以运行freetds tsql connection命令,几乎可以即时连接到各种mssql数据库(ec2上有一个,azure上有两个),但是同一命令在heroku bash提示符下超时:

~ $ tsql -H ***.rds.amazonaws.com -p 1433 -U *** -P ***
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
103Error 20002 (severity 9):
    Adaptive Server connection failed
Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server

FreeTDS本地和远程版本。在Heroku上安装Buildpack时,除了将TDS_VERSION设置为7. 3之外,我没有做任何特殊的“配置”文件设置。

# LOCAL:
$ tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds v1.3.13
             freetds.conf directory: /opt/homebrew/etc
     MS db-lib source compatibility: no
        Sybase binary compatibility: yes
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 7.3
                              iODBC: no
                           unixodbc: yes
              SSPI "trusted" logins: no
                           Kerberos: yes
                            OpenSSL: yes
                             GnuTLS: no
                               MARS: yes

# Heroku:
$ heroku run bash -a <app>
Running bash on ⬢ <app>... up, run.4557 (Hobby)
~ $ tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds v1.3.13
             freetds.conf directory: /app/freetds/etc
     MS db-lib source compatibility: no
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 7.3
                              iODBC: no
                           unixodbc: no
              SSPI "trusted" logins: no
                           Kerberos: no
                            OpenSSL: yes
                             GnuTLS: no
                               MARS: yes

如有任何想法,将不胜感激!

gzszwxb4

gzszwxb41#

这是由于TLS/openssl兼容性问题。现在使用gnutls修复该问题。
关于该问题的其他一些说明:https://github.com/FreeTDS/freetds/issues/336https://github.com/FreeTDS/freetds/issues/299显示器
如果您需要在heroku-22上使用freetds,请参阅此pull请求。https://github.com/rails-sqlserver/heroku-buildpack-freetds/pull/20
非常感谢@engineersmnky提出的一些很棒的问题,这些问题让我们找到了这个答案。

相关问题