[freetds] freetds failed to connect to MSSQL server ends with error ( Unable to open socket There was a problem connecting to the server )

Arlen Drina arlytex at gmail.com
Mon Sep 14 06:13:32 EDT 2009


I read all what is already suggssted here :

http://lists.ibiblio.org/pipermail/freetds/2009q3/024997.html

 I do know much about freetds so any help is welcome. Bellow are
outputs of proposed step on link above.
I have also debian+freetds 0.8.2 but I cannot connect to MSSQL server
using isql or tsql .

Suggestions are welcome. Thank you.



When I run

./tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds v0.82
             freetds.conf directory: /usr/local/etc
     MS db-lib source compatibility: no
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 8.0
                              iODBC: no
                           unixodbc: yes





TDSDUMPCONFIG=stderr TDSDUMP=stderr  sh -x ./osql -S mssql -U user  -P
password
(where osql is script recommended at
http://lists.ibiblio.org/pipermail/freetds/2009q3/024997.html  )


last lines in output are :

+ echo '[mssql]' found in '"/root/.odbc.ini"'
[mssql] found in "/root/.odbc.ini"
+ ODBC_INI=/root/.odbc.ini
+ break
+ '[' -z /root/.odbc.ini ']'
+ echo found this section:
found this section:
+ SED_CMD='/^\[mssql\]/,/^[[:space:]]*$/ { s/^/	/; p; }'
+ sed -ne '/^\[mssql\]/,/^[[:space:]]*$/ { s/^/	/; p; }' /root/.odbc.ini
	[mssql]
	Driver          = mssql
	#Driver          =/usr/lib/odbc/libtdsodbc.so
	Description     = MSSQL server
	Trace           = Yes
	Server          = mssql
	Port            = 1433
	#UID             = [admin]
	#PWD             = [pass]
	#LogonUser               = [admin]
	#LogonAuth               = [pass]
	TDS_Version=8.0
	
+ for D in '"${DSN}"' ''\''default'\'''
+ echo 'looking for driver for DSN [mssql]'
looking for driver for DSN [mssql]
+ grep mssql /root/.odbc.ini
+ '[' 0 -eq 0 ']'
+ CMD='/^\[mssql\]/,/^[[:space:]]*$/ { s/^/	/; p; }'
++ sed -ne '/^\[mssql\]/,/^[[:space:]]*$/ { s/^/	/; p; }' /root/.odbc.ini
++ grep -Ei '^[[:space:]]*driver[[:space:]]*='
+ DRIVER_LINE='	Driver          = mssql'
+ '[' -z '	Driver          = mssql' ']'
++ echo Driver = mssql
++ awk -F '[[:space:]]*=[[:space:]]*' '{print $2}'
+ DRIVER=
+ '[' '' ']'
++ basename /root/.odbc.ini
+ echo 'driver line incomplete for [mssql] in .odbc.ini' ---I do not
understand this one ...
driver line incomplete for [mssql] in .odbc.ini
+ continue
+ for D in '"${DSN}"' ''\''default'\'''
+ echo 'looking for driver for DSN [default]'
looking for driver for DSN [default]
+ grep default /root/.odbc.ini
+ '[' 1 -eq 0 ']'
+ '[' -z '' ']'
++ basename ./osql
++ basename /root/.odbc.ini
+ echo 'osql: error: no driver found for [mssql] in .odbc.ini'
osql: error: no driver found for [mssql] in .odbc.ini
+ exit 1




 ldd $(command -v isql)
	linux-gate.so.1 =>  (0xb7f29000)
	libodbc.so.1 => /usr/lib/libodbc.so.1 (0xb7ec1000)
	libodbcinst.so.1 => /usr/lib/libodbcinst.so.1 (0xb7eb6000)
	libreadline.so.5 => /lib/libreadline.so.5 (0xb7e83000)
	libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7e6a000)
	libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7d0f000)
	libltdl.so.3 => /usr/lib/libltdl.so.3 (0xb7d08000)
	libncurses.so.5 => /lib/libncurses.so.5 (0xb7cd6000)
	/lib/ld-linux.so.2 (0xb7f2a000)
	libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb7cd1000)


ls -l /usr/lib/odbc

-rw-r--r-- 1 root root   6048 2007-07-27 14:35 libesoobS.so
-rw-r--r-- 1 root root   5108 2007-07-27 14:35 libmimerS.so
-rw-r--r-- 1 root root  66128 2007-07-27 14:35 libnn.so
-rw-r--r-- 1 root root   3160 2007-07-27 14:35 libodbcdrvcfg1S.so
-rw-r--r-- 1 root root   2860 2007-07-27 14:35 libodbcdrvcfg2S.so
-rw-r--r-- 1 root root   3324 2007-07-27 14:35 libodbcminiS.so
-rw-r--r-- 1 root root   5912 2007-07-27 14:35 libodbcmyS.so
-rw-r--r-- 1 root root   2908 2007-07-27 14:35 libodbcnnS.so
-rw-r--r-- 1 root root   5624 2007-07-27 14:35 libodbcpsqlS.so
-rw-r--r-- 1 root root 146404 2007-07-27 14:35 libodbctxt.so
-rw-r--r-- 1 root root   4556 2007-07-27 14:35 libodbctxtS.so
-rw-r--r-- 1 root root   5840 2007-07-27 14:35 liboplodbcS.so
-rw-r--r-- 1 root root   3780 2007-07-27 14:35 liboraodbcS.so
-rw-r--r-- 1 root root   3032 2007-07-27 14:35 libsapdbS.so
-rw-r--r-- 1 root root 335520 2008-08-02 21:38 libtdsodbc.so
-rw-r--r-- 1 root root   4104 2007-07-27 14:35 libtdsS.so






#TDSDUMPCONFIG=stderr TDSDUMP=stderr  /usr/local/bin/tsql  -S mssql -U
user  -P password
log.c:190:Starting log file for FreeTDS 0.82
        on 2009-09-14 11:35:29 with debug flags 0x4fff.
config.c:172:Getting connection information for [mssql].
config.c:181:Attempting to read conf files.
config.c:310:... $FREETDSCONF not set.  Trying $FREETDS/etc.
config.c:323:... $FREETDS not set.  Trying $HOME.
config.c:253:Found conf file '/usr/local/etc/freetds.conf' (default).
config.c:398:Looking for section global.
config.c:455:   Found section global.
config.c:458:Got a match.
config.c:479:   tds version = '8.0'
config.c:479:   dump file = '/var/log/freetds.log'
config.c:479:   debug flags = '0xffff'
config.c:479:   timeout = '40'
config.c:479:   connect timeout = '40'
config.c:479:   text size = '64512'
config.c:455:   Found section mssql.
config.c:469:   Reached EOF
config.c:398:Looking for section mssql.
config.c:455:   Found section global.
config.c:455:   Found section mssql.
config.c:458:Got a match.
config.c:479:   host = '1.1.1.1'   ( here is correct IP address
--changed to 1.1.1.1 by me )
config.c:508:Found host entry 1.1.1.1.
config.c:512:IP addr is 1.1.1.1
config.c:479:   port = '1433'
config.c:479:   tds version = '8.0'
config.c:469:   Reached EOF
config.c:257:Success: [mssql] defined in /usr/local/etc/freetds.conf.
config.c:619:Setting 'dump_file' to 'stderr' from $TDSDUMP.
config.c:558:tds_config_login: client_charset is UTF-8.
config.c:195:Final connection parameters:
config.c:196:            server_name = mssql
config.c:197:                   port = 1433
config.c:198:          major_version = 8
config.c:199:          minor_version = 0
config.c:200:             block_size = 0
config.c:201:               language = us_english
config.c:202:         server_charset = iso_1
config.c:203:        connect_timeout = 40
config.c:204:       client_host_name = server
config.c:205:               app_name = TSQL
config.c:206:              user_name = user
config.c:209:                library = TDS-Library
config.c:210:              bulk_copy = 0
config.c:211:      suppress_language = 0
config.c:212:          encrypt level = 0
config.c:213:          query_timeout = 40
config.c:216:         client_charset = UTF-8
config.c:217:                ip_addr = 1.1.1.1.
config.c:218:          instance_name =
config.c:219:               database =
config.c:220:              dump_file = stderr
config.c:221:            debug_flags = ffff
config.c:222:              text_size = 64512
config.c:223:           broken_dates = 0
config.c:224:           broken_money = 0
config.c:225:     emul_little_endian = 0
11:35:29.422216 21769 (log.c:190):Starting log file for FreeTDS 0.82
        on 2009-09-14 11:35:29 with debug flags 0xffff.
11:35:29.422588 21769 (iconv.c:197):names for ISO-8859-1: ISO-8859-1
11:35:29.422725 21769 (iconv.c:197):names for UTF-8: UTF-8
11:35:29.422827 21769 (iconv.c:197):names for UCS-2LE: UCS-2LE
11:35:29.422927 21769 (iconv.c:197):names for UCS-2BE: UCS-2BE
11:35:29.423027 21769 (iconv.c:363):iconv to convert client-side data
to the "UTF-8" character set
11:35:29.423158 21769 (iconv.c:516):tds_iconv_info_init: converting
"UTF-8"->"UCS-2LE"
11:35:29.423294 21769 (iconv.c:516):tds_iconv_info_init: converting
"ISO-8859-1"->"UCS-2LE"
11:35:29.423411 21769 (net.c:210):Connecting to 1.1.1.1 port 1433 (TDS
version 8.0)
11:35:29.427509 21769 (net.c:264):tds_open_socket: connect(2) returned
"Operation now in progress"
11:35:29.970187 21769 (util.c:334):tdserror(0x90100a8, 0x90109d8, 20008, 4)
Msg 20008, Level 9, State -1, Server OpenClient, Line -1
Unable to open socket
11:35:29.970414 21769 (util.c:368):tdserror: client library returned
TDS_INT_CANCEL(2)
11:35:29.970519 21769 (util.c:389):tdserror: returning TDS_INT_CANCEL(2)
11:35:29.970621 21769 (net.c:310):tds_open_socket() failed
11:35:29.970737 21769 (mem.c:563):tds_free_all_results()
There was a problem connecting to the server






where are root/.odbc.ini and /etc/odbcinst.ini  as follows

/etc/odbcinst.ini:

[mssql]
Description             = FreeTDS 0.82-4, unixodbc 2.2.11-16
Driver                  = /usr/lib/odbc/libtdsodbc.so
TraceFile               = /var/log/sql.log
Trace                   = Yes
UsageCount              = 1




/root/.odbc.ini
[mssql]
Driver          = mssql
Description     = MSSQL server
Trace           = Yes
Server          = mssql
port            = 1433
#UID             = [admin]
#PWD             = [pass]
#LogonUser               = [admin]
#LogonAuth               = [pass]
TDS_Version=8.0




/usr/local/etc/freetds.conf
[mssql]

        host=mssql
	port = 1433
	tds version = 8.0





cat /etc/hosts

1.1.1.1   mssql


isql mssql user pass

I got

[ISQL]ERROR: Could not SQLConnect



Advices are welcome and thank you in advance

Regards,


Arlen






On Fri, Sep 11, 2009 at 8:22 PM,  <jklowden at schemamania.org> wrote:
> On Fri, Sep 11, 2009 at 11:33:20AM +0200, Arlen Drina wrote:
>> Hi all,
>>
>> I am using freetds 0.82 installed on Debian and I am trying to connect
>> to MSSQL 2005 server.
> ...
>> ./tsql -S sss.sss.sss.sss -U nagios -p 1433
>> locale is "en_US.UTF-8"
>> locale charset is "UTF-8"
>> Password:
>> Msg 20008, Level 9, State -1, Server OpenClient, Line -1
>> Unable to open socket
>> There was a problem connecting to the server
>
> Use TDSDUMP to get more detail about that error.
>
> "Unable to open socket" is TDSECONN produced by src/tds/net.c::tds_open_socket().  It's the result of a failure of inet_addr(3) or (more likely) socket(3).  While it's true you can't connect, more precisely you're prevented *locally* from attempting to connect.  To connect you need a  local resource -- a socket -- and you're unable to create one.
>
> I expect the log to show "socket creation error" and the OS's error message.  I wouldn't be surprised if EACCES is the problem.  (In which case telnet(1) will also fail.)
>
> HTH.
>
> --jkl
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>


More information about the FreeTDS mailing list