问题
I'm using FreeTDS 0.82 installed on OS X Snow Leopard to connect to a SQL Server 2005 database.
When I try to connect with tsql, I get this:
tsql -S abc -U uuu
locale is "en_US.UTF-8"
locale charset is "UTF-8"
Password:
Msg 20017, Level 9, State -1, Server OpenClient, Line -1
Unexpected EOF from the server
Msg 20002, Level 9, State -1, Server OpenClient, Line -1
Adaptive Server connection failed
There was a problem connecting to the serve
freetds.conf:
[abc]
Host = host.host.domain
port = 1433
tds version = 8.0
log file:
13:02:23.904572 97429 (log.c:190):Starting log file for FreeTDS 0.82 on 2011-04-20 13:02:23 with debug flags 0xffff.
13:02:23.904657 97429 (iconv.c:197):names for ISO-8859-1: ISO-8859-1
13:02:23.904669 97429 (iconv.c:197):names for UTF-8: UTF-8
13:02:23.904678 97429 (iconv.c:197):names for UCS-2LE: UCS-2LE
13:02:23.904686 97429 (iconv.c:197):names for UCS-2BE: UCS-2BE
13:02:23.904694 97429 (iconv.c:363):iconv to convert client-side data to the "UTF-8" character set
13:02:23.904715 97429 (iconv.c:516):tds_iconv_info_init: converting "UTF-8"->"UCS-2LE"
13:02:23.904729 97429 (iconv.c:516):tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE"
13:02:23.904744 97429 (net.c:210):Connecting to 174.46.169.40 port 1433 (TDS version 8.0)
13:02:23.904847 97429 (net.c:264):tds_open_socket: connect(2) returned "Operation now in progress"
13:02:23.966370 97429 (net.c:303):tds_open_socket() succeeded
13:02:23.966422 97429 (util.c:162):Changed query state from DEAD to IDLE
13:02:23.966433 97429 (login.c:735):quietly sending TDS 7+ login packet
13:02:23.966481 97429 (token.c:312):tds_process_login_tokens()
13:02:24.036207 97429 (util.c:334):tdserror(0x1001001d0, 0x100100840, 20017, 0)
13:02:24.036286 97429 (util.c:368):tdserror: client library returned TDS_INT_CANCEL(2)
13:02:24.036300 97429 (util.c:389):tdserror: returning TDS_INT_CANCEL(2)
13:02:24.036327 97429 (util.c:162):Changed query state from IDLE to DEAD
13:02:24.036338 97429 (token.c:316):looking for login token, got 0()
13:02:24.036478 97429 (token.c:108):tds_process_default_tokens() marker is 0()
13:02:24.036494 97429 (token.c:111):leaving tds_process_default_tokens() connection dead
13:02:24.036504 97429 (util.c:334):tdserror(0x1001001d0, 0x100100840, 20002, 0)
13:02:24.036614 97429 (util.c:368):tdserror: client library returned TDS_INT_CANCEL(2)
13:02:24.036626 97429 (util.c:389):tdserror: returning TDS_INT_CANCEL(2)
13:02:24.036639 97429 (mem.c:563):tds_free_all_results()
I've tried version 7.2, 7, etc and they all display the same thing.
回答1:
Try with
tds version = 7.0
Or set the following environment variable:
TDSVER="7.0"
Also make sure the port is correct, it may differ based on compile-time settings. You can set is in the environment too with:
TDSPORT="1433"
回答2:
I'm experimenting with MacOSX freetds:
I discovered that I had a .freetds.conf file in /Users that was overriding the main freetds.conf
After removing the .freetds.conf file all was OK
rm /Users/user/.freetds.conf
main file:
sudo vi /opt/local/etc/freetds/freetds.conf
回答3:
client charset = ISO-8859-1
in freetds.conf
solved the problem on OSX 10.8. / freetds 0.91
回答4:
We had this error intermittently after Linux and MS patches were applied. We could still connect from Linux to MSSQL server but randomly our connection would terminate with the EOF error...even in the middle of a query. I turned on the freetds log and saw an encryption handshake failure like this:
net.c:1366:handshake failed: A TLS packet with unexpected length was received.
login.c:466:login packet rejected
util.c:331:tdserror(0x1e752b0, 0x2c27f40, 20002, 0)
After much troubleshooting we rolled back KB3172605 on the MS Windows Server 2008 R2 server that runs our MS SQL Server DB...it resolved the problem.
回答5:
I had issues with the freetds.conf
apparently. setting tds version = 8.0 in freetds.conf
didn't work, in the dump log it kept sending INT CANCEL after the authorization steps. my php file ended up looking like this ultimately (the database and port settings in freetds.conf
worked fine... don't know why the tds version did not):
putenv('TDSVER=8.0');<br />
putenv('TDSDUMP=tds.log');<Br />
putenv('FREETDSCONF=freetds.conf');<br />
putenv('FREETDS=freetds.conf');
来源:https://stackoverflow.com/questions/5734018/freetds-displays-unexpected-eof-from-the-server