Dockerized Asp.net core 2.1 - Hangfire not starting - docker

Situation:
Use Hangfire with Asp.net core 2.1 and Docker.
App crashes on docker run. When I comment all codes related to
Hangfire, app works perfectly.
If I run the app via IIS express on Visual Studio, app works fine
with Hangfire.
Issue:
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
Connection strings on 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]"
},
Any idea guys why this is happening?
Thanks

Change the server values in your connection strings from LOCALHOST to be your ip

Related

TopShelf Service running fine in Visual studio during debug but when installed Throws exception

I am creating a TopShelf Windows Service which update records in the database. The service works fine in debug mode but when installed not working and throwing exception of "The underlying provider failed to Open".
I have tried SQl Authentication as well but the issue is still there

Container .NET Core Web App on Linux Docker SQL Server Connection

We have a .NET CORE web application running in Docker container on Linux. Our application connects to SQL Server. We have a requirement to connect to the database using Windows Authentication, and from my IIS experience I know that application needs to run within the context of the AD user that will be used to connect to SQL using Windows Auth.
Am I correct in this assumption? How do I define this with web app running on Kestrel in Linux Docker?

Serilog - not working on Client

I am using Serilog successfully in a WCF Service and it is outputting to a log file C:\Servicelog.txt on the hosting server. I configured Serilog in the same way on the Client application that consumes the service. When I run the Client application in debug mode when logged on to the server then it successfully outputs to my client logfile C:\Clientlog.txt.
However when I call the client through the browser from my own PC I am getting no output. I thought that it should continue to write to C:\Clientlog.txt on the hosting server. Checked whether it was been written to C:\Clientlog.txt on my PC - but it isn't. Appreciate any advise on why the client logging works only when the application is run from the hosting server ?

Cant connect to local MVC 4 api server with WP8 emulator

I have a little game project that uses a MVC 4 api server, however since I installed windows 8 / VS12 / WP8 SDK I havent been able to access the server from my app in the emulator, I can however access the deployed webserver.
Is there some sort of default firewall that would prevent me from contacting a localhost server? I just get a NotFound exception when I try, the localhost server works fine in my browser to retrieve some xml object
I have the same code working in windows 7 with vs2010 and wp7 sdk.
To connect to the server I use http://restsharp.org/
The emulator is running in Hyper-V, which is a virtual machine. It runs it's own network, and thus your PCs "localhost" isn't available from inside the virtual machine.
You don't have to set up a full IIS... you can go about with IIS express ( the visual studio way when you run the Web api solution ).
You need to do 2 things, first one check
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj684580(v=vs.105).aspx - only the part called 'Quick solution with IIS Express' ( parts 1 to 4 )
Second one, add a Microsoft Firewall rule to allow access from the VM to the IIS express.
Firewall > Advanced Settings > Rules for incoming > New port rule

Azure Compute Emulator can't connect to database after Upgrading to SQL Server 2008 R2

Until last week, I developed with SQL Server 2008 non-R2 and my ASP.NET MVC web application worked fine in the Azure Compute Emulator. It establishes a database connection while running.
After switching to SQL Server 2008 R2 (deinstalled the non-R2 verson before), my web application can't connect to the database anymore when running in the Compute Emulator.
Interesting: When I start my application outside of the Azure Compute Emulator, it works!
The exception:
System.Data.SqlClient.SqlException was unhandled by user code
Message=Cannot open database "X" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Any ideas? Thanks!
I guess your connection string is with "Integrated Security=True" (or SSPI). Your old server was configured to grand access to the target DataBase for user "Netword Service", while your new R2 installation isn't.
Moreover, when you run your app under Compute Emulator, it uses IIS to run your web role, thus, the default app pool identity (Network Service). However when you run your application without the Cloud Project (Compute Emulator) it uses the Casini (AKA Web Development Server), which runs under the account used for Visual Studio (guess elevated version of your user account). And because your user account does have access to the dabase, your application also has.
I highly suggest drop off any "integrated security" connection strings, and use against SQL Server users when developing Windows Azure applications, that target cloud deployment. SQL Azure only supports SQL Server Authenticatin/Authorization.
I had the same problem, but after removing "Integrated Security=True" from my connection string in web.config the mvc-app could not connect either, this time because of an Entity-Framework error.
But fortunately this workaround finally solved my problem!

Resources