Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Connection works only on second initialization #480

Open
schmandforke opened this issue Sep 30, 2020 · 1 comment
Open

SQL Connection works only on second initialization #480

schmandforke opened this issue Sep 30, 2020 · 1 comment

Comments

@schmandforke
Copy link

Environment

k8s 1.16
BaseContainer: ruby2.4
stable/freetds-1.00.27.tar.gz
gem 'tiny_tds', '2.1.3'

root@2fc6e5abbbd2:/usr/src/app# tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds v1.00.27
             freetds.conf directory: /usr/local/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: no

Description

I don't know why this issue is happing, can somebody give me a hint ?
here my irb:

opt = {:dataserver=>"10.10.10.10:1433", :username=>"myUser", :password=>"myPass", :port=>1433, :database=>"myDB"}
opt[:message_handler] = Proc.new { |m| puts m.message }

client = TinyTds::Client.new opt
Exception `TinyTds::Error' at /usr/local/bundle/gems/tiny_tds-2.1.3/lib/tiny_tds/client.rb:60 - Adaptive Server connection failed (10.10.10.10:1433)
TinyTds::Error: Adaptive Server connection failed (10.10.10.10:1433)
	from /usr/local/bundle/gems/tiny_tds-2.1.3/lib/tiny_tds/client.rb:60:in `connect'
	from /usr/local/bundle/gems/tiny_tds-2.1.3/lib/tiny_tds/client.rb:60:in `initialize'
	from (irb):111:in `new'
	from (irb):111
	from /usr/local/bin/irb:11:in `<main>'

client.execute("SELECT * FROM [myTable]").each{|res| p res }
TinyTds::Error: closed connection
	from (irb):122:in `execute'
	from (irb):122
	from /usr/local/bin/irb:11:in `<main>'

client.close
=> true

client = TinyTds::Client.new opt
Changed database context to 'myDB'.
=> #<TinyTds::Client:0x000055cd6bce0fc0 @message_handler=#<Proc:0x000055cd6bd41fa0@(irb):83>, @query_options={:as=>:hash, :symbolize_keys=>false, :cache_rows=>true, :timezone=>:local, :empty_sets=>true}>

client.execute("SELECT * FROM [myDB]").each{|res| p res }
=> {"ID"=>1, "MDT_ID"=>1...........}

why I need to initialize my client twice ? I can reproduce it, but doesn't know how to debug and I wouldn't implement a workaround with '2.time do' or 'begin rescue retry'

Would be nice if somebody can help.

Thanks a lot

@aharpervc
Copy link
Contributor

Hm, it seems much more likely that this is some sort of networking config problem than an issue with tiny_tds itself. For the first connection timeout, how long does that take to happen. The default login timeout is 60 seconds, is it before or after that point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants