Receiving "Error -4089 EAFNOSUPPORT address family not supported" in .Net Core 1.1 Web App on Azure - asp.net-core

I published a Web Api implemented in .Net Core 1.1 to Azure as an App Service but I keep receiving the error message below even when browsing a static html file:
2016-11-29 16:43:05.594 +00:00 [Warning] Unable to bind to http://localhost:28243 on the IPv6 loopback interface.
System.AggregateException: One or more errors occurred. (Error -4089 EAFNOSUPPORT address family not supported) ---> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -4089 EAFNOSUPPORT address family not supported
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind(UvTcpHandle handle, SockAddr& addr, Int32 flags)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListener.CreateListenSocket()
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<StartAsync>b__8_0(Object state)
--- 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 System.Threading.Tasks.Task.Wait()
at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.CreateServer(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application)
---> (Inner Exception #0) Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -4089 EAFNOSUPPORT address family not supported
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind(UvTcpHandle handle, SockAddr& addr, Int32 flags)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListener.CreateListenSocket()
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<StartAsync>b__8_0(Object state)<---
I googled it a bit and realized that there are a couple threads in git but none of them shed a light in resolving this issue. for e.g. one of them suggested to upload hosting.json file but that wasn't conclusive either. Any ideas how to resolve this issue?

Check for global.json file in solution root - do you have sdk version "for 1.1"? Something like
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-1-003177"
}
}

Related

factory.CreateConnection() generates a None of the specified endpoints were reachable;

We have a simple RabbitMQ .NET Client in ASP.NET Web App run under IIS 8. We do not use any SSL and the connection code is simple.
var factory = new ConnectionFactory()
{
HostName = hostname,
UserName = username,
Password = password,
VirtualHost = vhost,
Port = 5672
};
var connection = factory.CreateConnection();
The last line generates the following exception
Exception Occurred
Type: RabbitMQ.Client.Exceptions.BrokerUnreachableException
Message: None of the specified endpoints were reachable
Stack Trace: at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 505
at Org.Prod.Dependency.Concrete.Queuing.RabbitMqProdMessenger.SendMessage[TMessage](String hostname, String username, String password, String vhost, String target, TMessage message, Boolean targetIsExchange)
Source: RabbitMQ.Client
Inner Exception
Type: System.IO.IOException
Message: connection.start was never received, likely due to a network timeout
Stack Trace: at RabbitMQ.Client.Framing.Impl.Connection.StartAndTune() in /_/projects/RabbitMQ.Client/client/impl/Connection.cs:line 1074
at RabbitMQ.Client.Framing.Impl.Connection.Open(Boolean insist) in /_/projects/RabbitMQ.Client/client/impl/Connection.cs:line 707
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IFrameHandler fh) in /_/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs:line 646
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 495
Source: RabbitMQ.Client
Interestingly, when the same code is put in a console app and the binaries are shipped to the same server running the App, the console app connects fine and is able to publish messages.
What is wrong with Web Application trying to do the same thing the console app is doing?
It was an assembly binding failure of System.Threading.Tasks.Extensions, our exception logger was not logging the InnerException
Exception information:
Exception type: FileLoadException
Exception message: Could not load file or assembly 'System.Threading.Channels, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection..ctor(ConnectionFactory factory, String clientProvidedName)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 494
Very poor misleading error message.
In my case I received the exact same exception when calling factory.CreateConnection(); I am using RabbitMQ.Client 6.2.1 in a library that was dependant on System.Buffers 4.5.1 and my main assembly referenced System.Buffers 4.4.0, updated my main assembly to reference version 4.5.1 of System.Buffers, which involved a lot of other dependent Microsoft. and System. assemblies being removed first before I could remove then re-add System.Buffers via NuGet Package Manager as this told me I had 4.5.1 when my .csproj file said it was referencing 4.4.0. Once this reference issue was resolved the problem went away and I could connect to the RabbitMQ server.

How to fix or what causes The remote server returned an unexpected response error

I created an API and added swagger documentation in NET CORE 3.1 however when I deploy the web api to IIS on a remote server and try to make a call to one of the methods I receive the following error:
The remote server returned an unexpected response: (502) Proxy Error ( Forefront TMG denied the specified Uniform Resource Locator (URL). ).
Can somebody explain what causes that error? Everything works perfectly when I run the project locally.
[2020-08-26 12:12:33] [Server] [ERROR] [(null)] [? ?] [Application.Core.Helpers.Helper:?] - System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (502) Proxy Error ( Forefront TMG denied the specified Uniform Resource Locator (URL). ).
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.b__0(IAsyncResult asyncResult)
--- End of stack trace from previous location where exception was thrown ---

RavenDB Unable to boot server on local machine

i keep having the same problem for a few weeks now and i can't seem to figure out what it is.
I recently stared using RavenDB and it was working fine, but after a few days when i come home and want to boot the server on my local machine it just does not want to boot, it gives the following stack trace in the logs:
2019-03-05T18:58:43.0323063Z, 1, Operations, Server, Raven.Server.RavenServer, Failed to create a webhost to redirect HTTP traffic to HTTPS, EXCEPTION: System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransport.BindAsync()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass22_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
at Raven.Server.RavenServer.RedirectsHttpTrafficToHttps() in C:\Builds\RavenDB-Stable-4.1\41010\src\Raven.Server\RavenServer.cs:line 312
Now i am not very familiar with networking but i have no clue why initially it works for a few days and then it just stops working.
Any help would be greatly appreciated.
The most likely reason is that there is something that is already using the port that RavenDB is trying to bind into.
Check things like Get-NetTCPConnection output or netstat to verify that

NET Core 2.1 on Google Cloud Platform Failed to authenticate HTTPS connection TLS handshake failure with unexpected packet format

I am trying to set my web application up in Google Cloud Platform and use https. When the browser tries to connect over the https port Kestrel reports the following:
Hosting environment: Development
Content root path: /home/cvanem2/abc/HelloWorldAspNetCore
Now listening on: https://localhost:5001
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
dbug: HttpsConnectionAdapter[1]
Failed to authenticate HTTPS connection.
System.IO.IOException: The handshake failed due to an unexpected packet format.
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Security.SslState.ThrowIfExceptional()
at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__51_1(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(ConnectionAdapterContext context)ext)
I am having this issue on my production code, but it can also be easily produced with the provided sample code. Here are the instructions on how to reproduce the issue if you have a google cloud platform project setup:
Open the GCP terminal window
sudo apt-get -y install dotnet-sdk-2.1
dotnet new razor -o HelloWorldAspNetCore
cd HelloWorldAspNetCore/
dotnet dev-certs https
dotnet run
Set Web Preview to Port 5001 and try and open. The error will be shown in the terminal window
The same exact code runs fine on a Windows PC. I have also compiled the Windows code into a linux docker container on Windows and executed the docker. The issue occurs if the code is executed in the docker, so it appears to be related to the OS running the .net code. I tried to analyze the TLS packets from the Docker image with Wireshark but the data is encrypted after the first few packets and nothing appeared erroneous. Any help would be appreciated.
You can change the launchSettings.json, modify the http before the https
"WebApplication2": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
**"applicationUrl": "http://localhost:5000;https://localhost:5001"**
}

Microsoft Service Bus 1.1 configuration wizard fails - The LDAP server is unavailable

I use the service bus configuration wizard and, while everything seems fine during validation, in the end I get this:
[Error] [20/2/2014 11:07:14 ]: System.Management.Automation.CmdletInvocationException: The server could not be contacted. ---> System.DirectoryServices.AccountManagement.PrincipalServerDownException: The server could not be contacted. ---> System.DirectoryServices.Protocols.LdapException: The LDAP server is unavailable.
at System.DirectoryServices.Protocols.LdapConnection.Connect()
at System.DirectoryServices.Protocols.LdapConnection.SendRequestHelper(DirectoryRequest request, Int32& messageID)
at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request, TimeSpan requestTimeout)
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
--- End of inner exception stack trace ---
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
at System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, ContextOptions options, String userName, String password)
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType)
at System.DirectoryServices.AccountManagement.UserPrincipal.get_Current()
at Microsoft.ServiceBus.Commands.ServiceBusBaseCmdlet.CreateAdminGroup(String adminGroup)
at Microsoft.ServiceBus.Commands.NewSBFarmBase.ProcessRecordImplementation()
at Microsoft.ServiceBus.Commands.ServiceBusBaseCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
--- End of inner exception stack trace ---
at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
at Microsoft.ServiceBus.ConfigWizard.CommandletHelper.InvokePowershell(Command command, Action`3 updateProgress)
at Microsoft.ServiceBus.ConfigWizard.ProgressPageViewModel.CreateSBFarm(FarmCreationModel model)
Ideas anyone?
EDIT:
I have tried disabling my firewall completely, I enabled and started the "SQL Server Browser" service, tested my credentials, and I am completely clueless...
(I also have the SQL Server instance on my local machine, if that matters)
EDIT2:
After trying with another user account (the one I was inserting in the wizard) I got this:
[Error] [21/2/2014 10:24:39 πμ]: System.Management.Automation.CmdletInvocationException: Starting service Service Bus Gateway on machine TURBOX-PC failed: Time out has expired and the operation has not been completed. ---> Microsoft.ServiceBus.Commands.Common.Exceptions.OperationFailedException: Starting service Service Bus Gateway on machine TURBOX-PC failed: Time out has expired and the operation has not been completed. ---> System.ServiceProcess.TimeoutException: Time out has expired and the operation has not been completed.
at System.ServiceProcess.ServiceController.WaitForStatus(ServiceControllerStatus desiredStatus, TimeSpan timeout)
at Microsoft.ServiceBus.Commands.Common.SCMHelper.StartService(String serviceName, Nullable`1 waitTimeout, String hostName)
--- End of inner exception stack trace ---
at Microsoft.ServiceBus.Commands.Common.SCMHelper.StartService(String serviceName, Nullable`1 waitTimeout, String hostName)
at Microsoft.ServiceBus.Commands.ServiceBusConfigHelper.StartSBServices(String hostName, Nullable`1 waitTimeout)
at Microsoft.ServiceBus.Commands.AddSBHost.ProcessRecordImplementation()
--- End of inner exception stack trace ---
at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
at Microsoft.ServiceBus.ConfigWizard.CommandletHelper.InvokePowershell(Command command, Action`3 updateProgress)
at Microsoft.ServiceBus.ConfigWizard.ProgressPageViewModel.AddSBNode(FarmCreationModel model, Boolean isFirstCommand)
EDIT :
Using a different account and different port numbers (the default didn't work) I have managed to configure the SB, but now for some reason it still tries to use the default ports...
Does this thing work on ports other than the default ones?
If you are logged in as a domain user you need contact with the domain controller. This is what is failing for you.
I got this same error when trying to install service bus on my work laptop at home. When back at the office the installation was successful.
Some additional information about system requirements here: https://msdn.microsoft.com/en-us/library/dn441409.aspx