rails-sqlserver / tiny_tds

TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
Other
606 stars 190 forks source link

TinyTds::Error (Adaptive Server connection failed #473

Closed frenesim closed 4 years ago

frenesim commented 4 years ago

Before submitting an issue please check these first!

If none of these help. Please fill out the following:

Environment

Operating System No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04 LTS Release: 20.04 Codename: focal

TinyTDS Version and Information 2.1.2 I would love to have more information, but after I dig a little in gem source code I could go further the compile connect method inside TdsTiny::Client instantiation.

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

FreeTDS Version For now I'm trying to replicate another configuration and I'm using v1.1.6, but I also tried with versions 1.1.24 and 1.1.42.

Description

First of all thanks for your time to read this, hope you can give me some guidance. The all problem resumes to the fact that it have it work in other 2 linux OS (ubuntu 20.04 and CentOS 7), but suddenly it stopped working on a 3rd configuration where it was also working. So, everything was working until one day and I cannot remember what have I done beside 'regular' updates of my OS. Because of that and because I don't like to waste people time I mount a fresh ubuntu install (4th) and stumble on the same error. I always get the error TinyTds::Error (Adaptive Server connection failed (LXSQLCLGERAL.bar.lx)) despite the fact I can connect via jdbc with dbeaver and most important with tsql and tsql--ttds. To connect via tsql I'm doing tsql -S lxsqlclgeral -U svcsqlhb freetds.conf

[lxsqlclgeral]
        host = LXSQLCLGERAL.bar.lx
        instance = mssql_lxsqlclger
        tds version = 7.3
        charset = UTF-8
        database = gestaosi

On the rails project the failing connection is writen ilke this:

  establish_connection(
    adapter:  'sqlserver',
    # host:     'localhost',
    dataserver:  'LXSQLCLGERAL.bar.lx\MSSQL_LXSQLCLGER',
    pool: 10,
    timeout: 2000,
    username: Rails.application.credentials.dig(:development, :gestaosi, :username),
    password: Rails.application.credentials.dig(:development, :gestaosi, :password),
    database: 'gestaosi'
  )

As I said this connection is working in other development setting and in production. I'm spending hours with this issue, so I would really appreciate some guidance on what can I do more.

Cheers

frenesim commented 4 years ago

Finally I could work around this issue by removing every file created during build and install of freetds-1.1.24 and installing freetds-bin and freetds-dev packges from ubuntu repo.

prebm commented 3 years ago

It seems to be an encryption issue as stated in https://github.com/FreeTDS/freetds/issues/336#issuecomment-620870531

Alltough I can confirm the workaround in https://github.com/FreeTDS/freetds/issues/299#issuecomment-586160378 fixed the issue for me installing the ubuntu-repo version should be the preferred way.