I am using freetds to connect to SQL Server from ubuntu.
First, the SQL Server is running at port 1433 currently. I can telnet it. The following command also works. I can query table data using it,
sqsh -H 192.168.10.249 -p 1433 -H xx -P xxxxxx
however, this command does not work, and consequently making my ror app crash.
sqsh -S developer -U xxx -P xxxxxxxxx
this is error inside freetds.log
1:24:59.068648 5010 (log.c:190):Starting log file for FreeTDS 0.82 on 2012-06-04 11:24:59 with debug flags 0xffff.
11:24:59.069259 5010 (iconv.c:197):names for ISO-8859-1: ISO-8859-1
11:24:59.069298 5010 (iconv.c:197):names for UTF-8: UTF-8
11:24:59.069317 5010 (iconv.c:197):names for UCS-2LE: UCS-2LE
11:24:59.069335 5010 (iconv.c:197):names for UCS-2BE: UCS-2BE
11:24:59.069352 5010 (iconv.c:363):iconv to convert client-side data to the "UTF-8" character set
11:24:59.069394 5010 (iconv.c:516):tds_iconv_info_init: converting "UTF-8"->"UCS-2LE"
11:24:59.069461 5010 (iconv.c:516):tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE"
11:24:59.069492 5010 (net.c:836):tds7_get_instance_port(192.168.10.249, MSSQLSERVER)
11:25:00.070784 5010 (net.c:905):tds7_get_instance_port: timed out on try 0 of 16
11:25:01.072121 5010 (net.c:905):tds7_get_instance_port: timed out on try 1 of 16
11:25:02.073441 5010 (net.c:905):tds7_get_instance_port: timed out on try 2 of 16
11:25:03.074756 5010 (net.c:905):tds7_get_instance_port: timed out on try 3 of 16
...
11:25:15.095377 5010 (net.c:905):tds7_get_instance_port: timed out on try 15 of 16
11:25:15.095480 5010 (net.c:974):instance port is 0
11:25:15.095506 5010 (login.c:418):invalid port number
11:25:15.095532 5010 (mem.c:563):tds_free_all_results()
11:25:15.095580 5010 (ct.c:630):leaving ct_connect() returning 0
11:25:15.095605 5010 (ct.c:334):ct_con_props() action = CS_GET property = 9143
11:25:15.095630 5010 (ct.c:1865):ct_con_drop()
11:25:15.095652 5010 (ct.c:242):ct_exit()
this is my freetds.conf file
[global]
; tds version = 4.2
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
text size = 64512
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 5.0
[developer]
host = 192.168.10.249
port = 1433
#instance = MSSQLSERVER
tds version = 8.0
client charset = UTF-8
dump file = /home/daisy/freetds.log
dump file append = yes
debug flags = 0xffff
From the log output, I can see the program does not read the SQL Server port correctly in this case, it reads 0 which is wrong.
It also outputs some information relating to encoding. so I guess it may relate to the translation issue.
Best Answer
tds7_get_instance_port means freedts is using udp 1434 to query the port of the instance (source: net.c). But this should only be called if the instance is specified. Please doublecheck your freetds.conf