dotnet / SqlClient

Microsoft.Data.SqlClient provides database connectivity to SQL Server for .NET applications.
MIT License
860 stars 288 forks source link

SQL Server connection fails on centos,but succeeds on windows and in all other tools #62

Closed king311247 closed 5 months ago

king311247 commented 7 years ago

I'm running a webapi project by dotnetcore on centos.but it is failed to connect to MSSQL. In order to find the problem, I try to use the telnet to determine whether the server port, try to find the next is normal, and the project in the Windows environment are successful, the database can be connected, but deployed to centos is not connected to the database.

Error like this: Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HL30IKDGRVD6": An unhandled exception was thrown by the application. System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 35 - An internal exception was caught) ---> System.AggregateException: One or more errors occurred. (No such device or address) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No such device or address

Connection string example: Data Source=192.168.1.5\SQLSERVER2008;Initial Catalog=AwardSysDB;User ID=xx;Password=xx;min pool size=100;max pool size=250;

Data Source=192.168.1.5,1435;Initial Catalog=AwardSysDB;User ID=xx;Password=xx;min pool size=100;max pool size=250;

saurabh500 commented 7 years ago

Looking at the error it seems like the tcp connection between Sql server and the client cannot be established. Have you tried connecting to the server and port using a system utility to see if the network path is ok?

saurabh500 commented 7 years ago

You could try netcat if it is available. netcat -v -z ipaddress port

king311247 commented 7 years ago

@saurabh500 I installed the telnet tool on the deployment machine, telnet ipaddress port is successful

RocherKong commented 6 years ago

it's really can't work on centos when use sqlserver2008 for netcore2.1 . I have use sqlserver2014 to make it work without modify any other thing.

divega commented 5 years ago

As recently announced in the .NET Blog, focus on new SqlClient features an improvements is moving to the new Microsoft.Data.SqlClient package. For this reason, we are moving this issue to the new repo at https://github.com/dotnet/SqlClient. We will still use https://github.com/dotnet/corefx to track issues on other providers like System.Data.Odbc and System.Data.OleDB, and general ADO.NET and .NET data access issues.

David-Engel commented 5 months ago

SQL Server 2008 is long out of support and issue can't be repro'd on currently supported SQL versions.