{"action":"created","issue":{"url":"https://api.github.com/repos/ibmdb/ruby-ibmdb/issues/43","labels_url":"https://api.github.com/repos/ibmdb/ruby-ibmdb/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/ibmdb/ruby-ibmdb/issues/43/comments","events_url":"https://api.github.com/repos/ibmdb/ruby-ibmdb/issues/43/events","html_url":"https://github.com/ibmdb/ruby-ibmdb/issues/43","id":111725181,"number":43,"title":"Hanging instead of exception on IBM_DB.connect","user":{"login":"finalstep","id":496999,"avatar_url":"https://avatars.githubusercontent.com/u/496999?v=3","gravatar_id":"","url":"https://api.github.com/users/finalstep","html_url":"https://github.com/finalstep","followers_url":"https://api.github.com/users/finalstep/followers","following_url":"https://api.github.com/users/finalstep/following{/other_user}","gists_url":"https://api.github.com/users/finalstep/gists{/gist_id}","starred_url":"https://api.github.com/users/finalstep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finalstep/subscriptions","organizations_url":"https://api.github.com/users/finalstep/orgs","repos_url":"https://api.github.com/users/finalstep/repos","events_url":"https://api.github.com/users/finalstep/events{/privacy}","received_events_url":"https://api.github.com/users/finalstep/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-10-15T23:01:48Z","updated_at":"2015-10-20T07:28:01Z","closed_at":null,"body":"**Problem Description**\r\nWhen DB2 is not running, start irb and issue the command IBM_DB.connect(). ruby hangs indefinitely:\r\n```ruby\r\n    require 'ibm_db'\r\n    conn = IBM_DB.connect(\"mytest\", \"user\", \"password\")\r\n    # or\r\n    conn = IBM_DB.connect(\"DRIVER={IBM DB2 ODBC DRIVER};DATABASE=mytest;HOSTNAME=localhost;PORT=50000;PROTOCOL=TCPIP;UID=user;PWD=password;\", \"\", \"\")\r\n```\r\nAfter terminating irb, I note the status code is 146 which appears to be defined as BSM_ERRNO_ECONNREFUSED which makes sense. So it seems the code may detect the refused connection - is it then retrying forever or just 'stuck' somehow? The process does not recover when DB2 is started, indicating that its not able to retry in a recoverable way. \r\n\r\nWhen DB2 is running, both these commands return a working connection, so the connection string and credentials are correct. Not using rails. Not using Active Record.\r\n\r\n**Expected result**\r\nI'd expect to see some kind of error or exception. \r\nDocumentation says an Exception should be thrown.\r\nI saw another issue where a Connection Refused error was raised on OS X, so it seems that error is raised appropriately in a similar environment. \r\n\r\nAny ideas why the driver might hang? Or what I should do to get more debugging information about the source of the problem?\r\n\r\n**Alternative approaches/investigations**\r\n1. Yes, I could use ruby's Timeout::timeout to create my own timeout, but that requires another thread to establish each connection and Timeout brings other issues that I'd prefer to avoid if possible (especially since it seems that the error handling is already built into IBM_DB).\r\n2. Also tried adding tcp timeout parameter (its not clear to me if this is in fact supported in this context). It does not stop the code working when DB2 is running. It does not timeout the connection attempt when DB2 is not running.\r\n```    ...;PROTOCOL=TCPIP;TCPIPTIMEOUT=3;USER=...  ```\r\n3. Tried tracer.rb but it appears to be less appropriate when debugging C extensions\r\n\r\n\r\n**Environment**\r\n- Mac OS X 10.11\r\n- Ruby installed via brew\r\n- ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]\r\n- gem v.2.4.5.1\r\n- ibm_db (3.0.0 x86_64-darwin-14)\r\n- DB2 Express-C 10.1 for OS X installed to /Users/richard/sqllib\r\n- set environment before installing gem and before running test:\r\n```sh\r\n    IBM_DB_DIR=/Users/richard/sqllib/\r\n    IBM_DB_INCLUDE=/Users/richard/sqllib/include\r\n    IBM_DB_LIB=/Users/richard/sqllib/lib64\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ibmdb/ruby-ibmdb/issues/comments/149461976","html_url":"https://github.com/ibmdb/ruby-ibmdb/issues/43#issuecomment-149461976","issue_url":"https://api.github.com/repos/ibmdb/ruby-ibmdb/issues/43","id":149461976,"user":{"login":"finalstep","id":496999,"avatar_url":"https://avatars.githubusercontent.com/u/496999?v=3","gravatar_id":"","url":"https://api.github.com/users/finalstep","html_url":"https://github.com/finalstep","followers_url":"https://api.github.com/users/finalstep/followers","following_url":"https://api.github.com/users/finalstep/following{/other_user}","gists_url":"https://api.github.com/users/finalstep/gists{/gist_id}","starred_url":"https://api.github.com/users/finalstep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finalstep/subscriptions","organizations_url":"https://api.github.com/users/finalstep/orgs","repos_url":"https://api.github.com/users/finalstep/repos","events_url":"https://api.github.com/users/finalstep/events{/privacy}","received_events_url":"https://api.github.com/users/finalstep/received_events","type":"User","site_admin":false},"created_at":"2015-10-20T07:28:00Z","updated_at":"2015-10-20T07:28:00Z","body":"Hi Arvind,\n\nThanks for the precise instructions. The dump files are attached.\n\nyes, I can connect to the database using the DB2 command line tools:\n```\nrichard@aqua ~$ . sqllib/db2profile\nrichard@aqua ~$ db2 connect to mytest\n\n   Database Connection Information\n\n Database server        = DB2/DARWIN 10.1.0\n SQL authorization ID   = RICHARD\n Local database alias   = MYTEST\n```\n\n\n\n> On 20 Oct 2015, at 5:35 PM, Arvind Gupta <notifications@github.com> wrote:\n> \n> ./db2trc flw /db2trc.dump /db2trc.flw\n\n"}}