Skip to Content.
Sympa Menu

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

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Pulver, Alex" <alex.pulver AT intel.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Getting "Unexpected EOF from the server" when trying to connect to MS SQL Server 2014
  • Date: Mon, 25 Apr 2016 14:38:56 +0000

Thanks Frediano! Your input helped to resolve this :)

The problem was combination of two things:
* Our current FreeTDS installation was compiled with OpenSSL 0.9.8, and
probably the server was using a newer version for handshake.
* I was trying to use TDSVER=7.0 in all recent attempts, and didn't try to
bump it again.

To summarize, the following worked:
* Compile FreeTDS with OpenSSL 1.0.1: ./configure
--with-openssl=/.../openssl/1.0.1/bin/openssl
* Try connecting with TDSVER=7.2 (8.0 also works of course): env TDSVER=8.0
/.../tsql -H <host> -p <port> -U <username> -P <password> -D <database>

Regards,
Alex


-----Original Message-----
From: FreeTDS [mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of
Frediano Ziglio
Sent: Monday, April 25, 2016 17:14
To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
Subject: Re: [freetds] Getting "Unexpected EOF from the server" when trying
to connect to MS SQL Server 2014

2016-04-25 13:26 GMT+01:00 Pulver, Alex <alex.pulver AT intel.com>:
> 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
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.





Archive powered by MHonArc 2.6.24.

Top of Page