Run Kestrel on bash on windows - linux

I'm trying to run a simple web site on bash on windows (Windows Anniversary update bash) but I've been so far unsuccessfully.
I'm able to create and run console app, but whenever I type
dotnet run
on a web project, I get:
Unhandled Exception: System.AggregateException: One or more errors occurred. (Error -98 EADDRINUSE address already in use) ---> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -98 EADDRINUSE address already in use
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.Check(Int32 statusCode)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.GetSockIPEndPoint()
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListenerPrimary.CreateListenSocket()
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<>c.<StartAsync>b__6_0(Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.ListenerPrimary.<StartAsync>d__11.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.CreateServer(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token, String shutdownMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at WebApplication.Program.Main(String[] args)
Has anyone been successful in this? Am I asking too much of that "stripped-down-beta linux version"?
EDIT:
To reproduce the behavior, on a bash on windows prompt I type:
mkdir mytestwebsite
cd mytestwebsite
dotnet new -t web
dotnet restore
dotnet run
and then the problem appears.

The important part of that error message is this:
Error -98 EADDRINUSE address already in use
This is saying that something is already bound to the port you are trying to listen on. For example, if you are trying to run Kestrel and listen on port 80 (the default HTTP port) then Apache may also be already attached. You either need to shut down whatever is already listening on that port or change your app to pick a new port.

Related

Failed to deploy web package to App Service. Service Unavailable (CODE: 503)

I am trying to deploy my app to an Azure app service via Azure Dev Ops pipelines. The app builds okay, but during the deploy phase, I get the following error.
2023-01-12T19:23:13.1683884Z ##[error]Failed to deploy web package to App Service.
2023-01-12T19:23:13.1696403Z ##[error]Error: Error: Failed to deploy web package to App Service. Service Unavailable (CODE: 503)
It has failed consistently multiple times in a row, after working fine for the past couple of weeks.
Full log
2023-01-12T19:21:10.6967333Z ##[section]Starting: Deploy
2023-01-12T19:21:10.6981944Z ==============================================================================
2023-01-12T19:21:10.6982213Z Task : Azure App Service deploy
2023-01-12T19:21:10.6982366Z Description : Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby
2023-01-12T19:21:10.6982681Z Version : 4.214.0
2023-01-12T19:21:10.6982809Z Author : Microsoft Corporation
2023-01-12T19:21:10.6982961Z Help : https://aka.ms/azureappservicetroubleshooting
2023-01-12T19:21:10.6983137Z ==============================================================================
2023-01-12T19:21:11.2444263Z Got service connection details for Azure App Service:'REDACTED'
2023-01-12T19:22:18.8337786Z Package deployment using ZIP Deploy initiated.
2023-01-12T19:23:13.1683884Z ##[error]Failed to deploy web package to App Service.
2023-01-12T19:23:13.1696403Z ##[error]Error: Error: Failed to deploy web package to App Service. Service Unavailable (CODE: 503)
2023-01-12T19:23:13.9090032Z Successfully added release annotation to the Application Insight : [REDACTED]
2023-01-12T19:23:14.0064590Z ##[warning]Error: Failed to update deployment history. Error: Service Unavailable (CODE: 503)
2023-01-12T19:23:14.2708516Z App Service Application URL: https://REDACTED.azurewebsites.net
2023-01-12T19:23:14.2790032Z ##[section]Finishing: Deploy
I tried to redeploy an older release that previously worked, but I got the same errors.
I also tried to publish to my app service from Visual Studio. It failed with the following error.
Error MSB4018: The "ZipDeploy" task failed unexpectedly.
Full Error
Error MSB4018: The "ZipDeploy" task failed unexpectedly.
System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
--- End of inner exception stack trace ---
at System.Net.ConnectStream.EndRead(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.WebExceptionWrapperStream.EndRead(IAsyncResult asyncResult)
at System.Net.Http.StreamToStreamCopy.StartRead()
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.NET.Sdk.Publish.Tasks.ZipDeploy.HttpClientHelpers.<PostWithBasicAuthAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.NET.Sdk.Publish.Tasks.ZipDeploy.ZipDeploy.<ZipDeployAsync>d__26.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.NET.Sdk.Publish.Tasks.ZipDeploy.ZipDeploy.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
---> (Inner Exception #0) System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
--- End of inner exception stack trace ---
at System.Net.ConnectStream.EndRead(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.WebExceptionWrapperStream.EndRead(IAsyncResult asyncResult)
at System.Net.Http.StreamToStreamCopy.StartRead()
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.NET.Sdk.Publish.Tasks.ZipDeploy.HttpClientHelpers.<PostWithBasicAuthAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.NET.Sdk.Publish.Tasks.ZipDeploy.ZipDeploy.<ZipDeployAsync>d__26.MoveNext()<---
Could this a temporary problem with the zip deployment service? The Azure service status page doesn't currently show any issues.
Turns out my App Service was overloaded. I scaled-up to the next plan, and I was able to deploy again.

Win 10 -> VS 2019 -> .NET Core 3 WPF application -> Publish to directory (self-contained for linux-x64) -> Publish failed

Weird issue I've faced today.
Pre-requisites:
Installed:
VS2019
.NET Core 3.0
Steps to reproduce the issue:
Create new "WPF App (.NET Core)"
To the MainWindow.xaml add single TextBlock:
<TextBlock Text="WPF on Linux" TextWrapping="Wrap"/>
Create new Publish Profile like the following:
Then save and publish
Expected to see the application being published. But instead the following message pops up:
And here is the content of the mentioned in the error message file:
2019-10-28 19:39:43
System.AggregateException: One or more errors occurred. ---> System.Exception: Publishing failed.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.Publish.Framework.Model.DefaultPublishSteps.<>c__DisplayClass26_0.<IsBuildCompletedSuccessfully>b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Publish.Framework.Model.DefaultPublishSteps.<DefaultCorePublishStep>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__202.MoveNext()
---> (Inner Exception #0) System.Exception: Publishing failed.<---
System.Exception: Publishing failed.
===================
The question is.. What am I doing wrong and/or how to fix the issue?
Important note:
If Deployment Mode is set to "Framework Dependent", and the Target Runtime is "linux-x64" then the project is published into the directory with no issues.
If Deployment Mode is set to "Self-contained", but Target Runtime is "win-x64", then deployment works with no issues.
The error is in the build output window:
There was no runtime pack for Microsoft.WindowsDesktop.App.WPF available for the specified RuntimeIdentifier 'linux-x64'
WPF is not supported on Linux, only Windows.

Dotnet Core 2.0 Web App Publish to Azure Fails

From VS 2017
what I tried:
Build in release mode & debug mode both builds fine.
Set Build verbosity to Diagnostic, there is not much information
indicating code error.
However .tmp dump file indicates some error.
I suspect these are visual studio internal errors:
5/4/2018 9:34:44 PM
System.AggregateException: One or more errors occurred. ---> System.Exception: Publish failed due to build errors. Check the error list for more details.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass40_0.<PublishAsync>b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__88.MoveNext()
---> (Inner Exception #0) System.Exception: Publish failed due to build errors. Check the error list for more details.<---
===================
Setting RazorCompileOnBuild property to true should resolve your problem.
Take a look on following question
Had to set build verbosity to diagnostics then found out there were some errors in un-used Razor view pages.
There must be a way to compile Razor during build time rather than when publishing.

.NET Core deployment to IIS error for the standard .NET Core web application

I am trying to deploy a .NET Core 2.0 application to IIS. This is just the standard .NET Core web application that is created when starting a new project. The project builds and run just fine. However, when trying to publish to IIS via web deploy, I get the following error:
3/25/2018 3:45:08 PM
System.AggregateException: One or more errors occurred. ---> System.Exception: Publish failed due to build errors. Check the error list for more details.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass40_0.<PublishAsync>b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__88.MoveNext()
---> (Inner Exception #0) System.Exception: Publish failed due to build errors. Check the error list for more details.<---
===================
Am I missing something?

webjob aborts with exception somehow due to idling to long

I am extracting a .zip archive on azure webjob.
That worked ok for some time.
Now the webjob suddenly started to fail:
[12/11/2017 16:59:57 > bf607f: ERR ] Command 'cmd /c ""run.cmd""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""run.cmd""
[12/11/2017 16:59:57 > bf607f: ERR ] replace D:\home\site\store\extracted/documents/6465465465466015.pdf? [y]es, [n]o, [A]ll, [N]one, [r]ename:
[12/11/2017 16:59:57 > bf607f: SYS INFO] Status changed to Failed
[12/11/2017 16:59:57 > bf607f: SYS ERR ] System.AggregateException: One or more errors occurred. ---> Kudu.Core.Infrastructure.CommandLineException: Command 'cmd /c ""run.cmd""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""run.cmd""
at Kudu.Core.Infrastructure.IdleManager.WaitForExit(IProcess process)
at Kudu.Core.Infrastructure.ProcessExtensions.<Start>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Kudu.Core.Infrastructure.Executable.<ExecuteAsync>d__31.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at Kudu.Core.Infrastructure.Executable.ExecuteInternal(ITracer tracer, Func`2 onWriteOutput, Func`2 onWriteError, Encoding encoding, String arguments, Object[] args)
at Kudu.Core.Infrastructure.Executable.ExecuteReturnExitCode(ITracer tracer, Action`1 onWriteOutput, Action`1 onWriteError, String arguments, Object[] args)
at Kudu.Core.Jobs.BaseJobRunner.RunJobInstance(JobBase job, IJobLogger logger, String runId, String trigger, ITracer tracer, Int32 port)
---> (Inner Exception #0) ExitCode: -1, Output: Command 'cmd /c ""run.cmd""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed., Error: Command 'cmd /c ""run.cmd""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed., Kudu.Core.Infrastructure.CommandLineException: Command 'cmd /c ""run.cmd""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""run.cmd""
at Kudu.Core.Infrastructure.IdleManager.WaitForExit(IProcess process)
at Kudu.Core.Infrastructure.ProcessExtensions.<Start>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Kudu.Core.Infrastructure.Executable.<ExecuteAsync>d__31.MoveNext()<---
I mean it seems when the exception happened the webjob was pretty busy, so why do I get that idle timeout exception?
I would suggest you add SCM_COMMAND_IDLE_TIMEOUT and WEBJOBS_IDLE_TIMEOUT setting in your Web App ‘App settings’ configuration with a value of your choice.
For example:
SCM_COMMAND_IDLE_TIMEOUT = 3600
WEBJOBS_IDLE_TIMEOUT = 3600
You may turn on the ‘Always On’ feature if not enabled and see if that helps.
By default, Web Apps are unloaded if they are idle for some period of time. This lets the system conserve resources. In Basic or Standard mode, you can enable ‘Always On’ to keep the app loaded all the time. If your app runs continuous WebJobs, you should enable ‘Always On’, or the WebJobs may not run reliably. To enable, Goto web app -> Settings -> Application Settings -> enable ‘Always On’.
Also, refer diagnostic log stream to get more details on this issue.
I mean it seems when the exception happened the webjob was pretty busy, so why do I get that idle timeout exception?
Root Cause:
There is no output in the console for long time.
Solution:
We also could do as Ashok metioned to increase WEBJOBS_IDLE_TIMEOUT value.This should be set in the configuration setting for the Web App, rather than in the App.config of the WebJob. And the value is in second.
You also could add output to the console every minute. More details could refer to this blog.
Another solution is to add output to the Console, which is especially useful for jobs that are doing long running asynchronous tasks or polling external services, For these cases adding a heartbeat style Console write every minute is better than increasing the Idle Timeout to huge numbers

Resources