Re: Getting "Unexpected EOF from the server" when trying to connect to MS SQL Server 2014

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CAHt6W4f-4urw3m-YYRoYY8wJu_aCTB91TTbA7QLqH=Hpt5i=TQ@mail.gmail.com>
2016-04-25 13:26 GMT+01:00 Pulver, Alex <[email protected]>:
> Hi all,
>
> I am trying to connect to MS SQL 2014 Server from SLES11 host, using FreeTDS 0.95.51 version and its tsql utility. The server uses "Standard Mode" (SQL Server Authentication) and I am able to connect from Windows using SQL Server 2014 Management Studio.
> Before sending this email I've read through FreeTDS troubleshooting, FAQ, domains page, config page, archives and various SO questions - tried the recommended configurations but with no luck (details below).
>
> The command being run is:
> env TDSVER=7.0 TDSDUMP=/tmp/tdsdump.log TDSDUMPCONFIG=/tmp/tdsdumpconfig.log ./src/apps/tsql -H <host> -p <port> -U <username> -P <password> -D <database>
>

I would try with at least 7.2 version.

> The output:
> locale is "C"
> locale charset is "ANSI_X3.4-1968"
> using default charset "ISO-8859-1"
> Setting <database> as default database in login packet
> Error 20017 (severity 9):
>         Unexpected EOF from the server
> ...
>
> Tailing TDSDUMP along with the execution shows that error is happening after the login packet is sent and FreeTDS tries to process the login tokens:
> login.c:852:quietly sending TDS 7+ login packet
> token.c:327:tds_process_login_tokens()
> <<
> Error 20017 (severity 9):
>         Unexpected EOF from the server
>>>
> query.c:3772:tds_disconnect()
>
> Looking on strace seems to confirm that server disconnects after login packet is received (poll() returns positive after sendto(), but recvfrom() returns 0):
> write(5, "login.c:852:quietly sending TDS "..., 48) = 48
> ...
> poll([{fd=6, events=POLLOUT}, {fd=4, events=POLLIN}], 2, -1) = 1 ([{fd=6, revents=POLLOUT}])
> sendto(6, "\20\1\0012\0\0\0\0*\1\0\0\0\0\0p\0\20\0\0\6\203\362\370U\354\0\0\0\0\0\0"..., 306, MSG_NOSIGNAL, NULL, 0) = 306
> write(5, "token.c:327:tds_process_login_to"..., 39) = 39

This means that server rejected the login. Like user/password wrong.
Are you using Kerberos/SSPI or SQL logins?

> poll([{fd=6, events=POLLIN}, {fd=4, events=POLLIN}], 2, -1) = 1 ([{fd=6, revents=POLLIN}])
> recvfrom(6, "", 8, MSG_NOSIGNAL, NULL, NULL) = 0
> write(5, "query.c:3772:tds_disconnect() \n", 31) = 31
>
> Things I tried listed in no particular order (assuming the issue is with authentication and not network):
> * Use UTF-8 encoding

This would change if you have extra ASCII in your username/password.

> * Disable SSPI: ./configure --disable-sspi (so that trusted authentication will not be triggered)

SSPI is supported only in Windows so it's not affecting your build.

> * Compile with latest OpenSSL version we have installed: ./configure --with-openssl=/.../openssl/1.0.1/bin/openssl
> * Explicitly disable OpenSSL: ./configure --without-openssl
> * Modifying the code in ./src/tds/mem.c to disable check_ssl_hostname by setting it to 0 in both places it appears (assuming it triggers checking server's SSL certificate and fails to authenticate). Verified using debugger that *((tds)->login) object has check_ssl_hostname set to 0
> * Modifying the code in ./src/tds/tls.c to change location of certificates pointed by ca_directory[] to a directory I know we have updated internal certificates
>

No, the check is done by FreeTDS, in this case the server is disconnecting.

> Things I still need to check with MS SQL Server admins:
> * Try to see if they can give me access to server-side log for my connection attempts
> * Check if server requires two-way authentication for SQL Server Authentication - doesn't seem like it, but I will check
>
> If someone has any other ideas as to why the connection drops, or other things I can do to investigate further, I would really appreciate that!
>

You could try increasing the log level (see "debug flags" in
http://www.freetds.org/userguide/freetdsconf.htm).
Also I would try the "use ntlmv2" flag (same page above).

> Thanks!
> Alex

Frediano
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.