Dockerized Asp.net Core 2.1-Hangfire无法启动

时间:2018-09-16 12:55:36

标签: docker asp.net-core hangfire asp.net-core-2.1

情况: 将Hangfire与Asp.net core 2.1和Docker结合使用。

  • 应用程序在docker运行时崩溃。当我评论所有与 Hangfire,应用程序运行完美。

  • 如果我通过Visual Studio上的IIS Express运行该应用程序,则该应用程序可以正常运行
    使用Hangfire。

问题:

Application startup exception: System.Exception: Cannot connect to SQL Server Browser. Ensure SQL Server Browser has been started. ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No such device or address
\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\


    at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Hangfire.HangfireApplicationBuilderExtensions.ThrowIfNotConfigured(IApplicationBuilder app)
   at Hangfire.HangfireApplicationBuilderExtensions.UseHangfireServer(IApplicationBuilder app, BackgroundJobServerOptions options, IEnumerable`1 additionalProcesses, JobStorage storage)

error on docker run

appsettings.json上的连接字符串:

"ConnectionStrings": {
"TestDB": "Server=[server_instance]\\LOCALHOST;database=[db1];uid=[user];pwd=[pwd]",
"HangfireDB": "Server=[server_instance]\\LOCALHOST;database=Hangfire;uid=[user];pwd=[pwd]"
  },

任何主意,为什么会这样? 谢谢

1 个答案:

答案 0 :(得分:0)

将连接字符串中的服务器值从LOCALHOST更改为您的ip