简体   繁体   中英

ASP.NET MVC on Windows IoT raspberry pi unable to connect to SQL database

I'm trying to start MusicStore application at Raspberry Pi 3 using Windows IoT system with .NET Core 2.0.4.

I managed to run it on Raspberry using ubuntu, but in Windows, I get an error from screenshot (sorry for not copying it but I didn't get error in putty so I need to use Windows IoT command line and I'm not able to copy this text anywhere).

Both systems were connecting to the database on my PC and linux was able to run application, while Windows is failing, so this is not fault of connection string. I previously had problem with missing sni.dll but as suggested in this thread I repaired it by copying unix.

Any ideas what's wrong?

EDIT: Today i tested it on my old PC (win10-x64) i got same error as on Windows-IoT so i can copy it here.

Unhandled Exception: System.AggregateException: One or more errors occurred. (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: SQL Network Interfaces, error: 44 - Could not compose Service Principal Name (SPN) for Windows Integrated Authentication. Possible causes are server(s) incorrectly specified to connection API calls, Domain Name System (DNS) lookup failure or memory shortage)) ---> 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: SQL Network Interfaces, error: 44 - Could not compose Service Principal Name (SPN) for Windows Integrated Authentication. Possible causes are server(s) incorrectly specified to connection API calls, Domain Name System (DNS) lookup failure or memory shortage) ---> System.Net.Sockets.SocketException: Nieznany host
    at System.Net.Dns.InternalGetHostByAddress(IPAddress address)
    at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
    at System.Data.SqlClient.SNI.SNIProxy.GetSqlServerSPN(String hostNameOrAddress, String portOrInstanceName)
    at System.Data.SqlClient.SNI.SNIProxy.GetSqlServerSPN(DataSource dataSource)
    at System.Data.SqlClient.SNI.SNIProxy.CreateConnectionHandle(Object callbackObject, String fullServerName, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Byte[]& instanceName, Byte[]& spnBuffer, Boolean flushCache, Boolean async, Boolean parallel, Boolean isIntegratedSecurity)
--- End of inner exception stack trace ---
    at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)
    at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
    at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
    at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
    at System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()
--- End of stack trace from previous location where exception was thrown ---
    at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
    at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerDatabaseCreator.<>c__DisplayClass20_0.<<ExistsAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerDatabaseCreator.<>c__DisplayClass20_0.<<ExistsAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
    at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.EnsureCreatedAsync(CancellationToken cancellationToken)
    at MusicStore.Models.SampleData.InitializeMusicStoreDatabaseAsync(IServiceProvider serviceProvider, Boolean createUsers) in C:\Users\lukas\Documents\projekty\magister\MusicStore\Models\SampleData.cs:line 27
--- End of inner exception stack trace ---
    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
    at System.Threading.Tasks.Task.Wait()
    at MusicStore.Startup.Configure(IApplicationBuilder app) in C:\Users\lukas\Documents\projekty\magister\MusicStore\Startup.cs:line 220
    at MusicStore.Startup.ConfigureProduction(IApplicationBuilder app) in C:\Users\lukas\Documents\projekty\magister\MusicStore\Startup.cs:line 171
--- End of stack trace from previous location where exception was thrown ---
    at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
    at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
    at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
    at MusicStore.Program.Main(String[] args) in C:\Users\lukas\Documents\projekty\magister\MusicStore\Program.cs:line 67

As far as i know, Windows IoT Core on arm has not ability to connect to MS SQL Server.You can trace the issue( #9064 ) on GitHub. You can use additional web service or wcf and communicate over REST-API to work around.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM