Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Kestrel startup sample code with file descriptor for 3.0 #13744

Closed
1 of 3 tasks
xfoxfu opened this issue Aug 9, 2019 — with docs.microsoft.com · 12 comments
Closed
1 of 3 tasks

Update Kestrel startup sample code with file descriptor for 3.0 #13744

xfoxfu opened this issue Aug 9, 2019 — with docs.microsoft.com · 12 comments
Labels
Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

Copy link

xfoxfu commented Aug 9, 2019

Issue description

The sample code provided in AspNetCore.Docs/aspnetcore/fundamentals/servers/kestrel/samples/2.x/KestrelSample/Program.cs fails to start up when FileDescriptor defined on Dotnet Core 3.0 preview.

The command line outputs:

crit: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to start Kestrel.
System.NotImplementedException: This property is not implemented by this class.
   at System.Net.EndPoint.get_AddressFamily()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass21_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.EndpointsStrategy.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)
Unhandled exception. System.NotImplementedException: This property is not implemented by this class.
   at System.Net.EndPoint.get_AddressFamily()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass21_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.EndpointsStrategy.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.WebHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at KestrelSample.Program.Main(String[] args) in /AspNetCore.Docs/aspnetcore/fundamentals/servers/kestrel/samples/2.x/KestrelSample/Program.cs:line 74

Software versions

Check the .NET target framework(s) being used, and include the version number(s).

  • .NET Core netcoreapp3.0
  • .NET Framework
  • .NET Standard

If using the .NET Core SDK, include dotnet --info output. If using .NET Framework without the .NET Core SDK, include info from Visual Studio's Help > About Microsoft Visual Studio dialog.

dotnet --info output or About VS info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview7-012821
 Commit:    6348f1068a

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.0.100-preview7-012821/

Host (useful for support):
  Version: 3.0.0-preview7-27912-14
  Commit:  4da6ee6450

.NET Core SDKs installed:
  3.0.100-preview7-012821 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.0-preview7-27912-14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
@dotnet-bot dotnet-bot added the Source - Docs.ms Docs Customer feedback via GitHub Issue label Aug 9, 2019
@guardrex
Copy link
Collaborator

guardrex commented Aug 9, 2019

Hello ... We aren't able to provide product support. Your best option is to consult with devs on a support forum, such as Stack Overflow, or a support chat, such as Slack or Gitter. If you think that you found a framework bug, open an issue on the engineering repo.

@guardrex guardrex closed this as completed Aug 9, 2019
@Rick-Anderson
Copy link
Contributor

Can you create an issue from the doc page? That will connect the doc to the issue. Go to the bottom of the page and select the Content feedback issue.
image

@Rick-Anderson
Copy link
Contributor

@guardrex - I asked @coderfox to open an integrated issued from the doc page and ask to update the topic to 3.0. That's a valid doc issue.

@Rick-Anderson
Copy link
Contributor

@guardrex see #13743

@guardrex
Copy link
Collaborator

guardrex commented Aug 9, 2019

Actually, this more of a @tdykstra thing.

I'll note in passing that AFAIK we have all of the ListenOptions coverage that engineering requested. For any error like that between 2.2 and 3.0, I recommend an engineering issue. If they surface a delta for a given scenario for 3.0 or if they agree that the doc doesn't cover an implementation scenario, then we would normally re-open over here and work it. This isn't actionable here in its current form.

Anywho ---- this is more of a @tdykstra area of the TOC, so I defer to my friend on this one.

@guardrex guardrex reopened this Aug 9, 2019
@tdykstra
Copy link
Contributor

tdykstra commented Aug 9, 2019

this is more of a @tdykstra area of the TOC

@guardrex But you have #12842 - Kestrel 3.0 updates, which includes the sample app

@Rick-Anderson
Copy link
Contributor

Closing because it's a duplicate of #12842

@guardrex
Copy link
Collaborator

guardrex commented Aug 9, 2019

when FileDescriptor defined

@coderfox, you're using custom code that generates that error, correct? ... i.e., this isn't an OOB template app, correct?

@xfoxfu
Copy link
Author

xfoxfu commented Aug 10, 2019

@guardrex I can't quite catch up with the meaning of OOB template, but I modified nothing of the sample code except the beginning #define instruction and the target framework.

In your sample code, there are multiple sections of starting the application and bind to a socket, and I am just using the section of binding to existing file descriptors by defining FileDescriptor instead of the default one.

@guardrex
Copy link
Collaborator

guardrex commented Aug 10, 2019

@coderfox Try the following and see if it runs ...

Project File

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>
  
</Project>

Program.cs

using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace KestrelSample
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.ConfigureKestrel(serverOptions =>
                    {
                        var fds = Environment
                            .GetEnvironmentVariable("SD_LISTEN_FDS_START");
                        var fd = ulong.Parse(fds);

                        serverOptions.ListenHandle(fd);
                        serverOptions.ListenHandle(fd, listenOptions =>
                        {
                            listenOptions.UseHttps("testCert.pfx", "testpassword");
                        });
                    })
                    .UseStartup<Startup>();
                });
    }
}

@xfoxfu
Copy link
Author

xfoxfu commented Aug 10, 2019

@guardrex No. Exactly the same exception is thrown.

@guardrex
Copy link
Collaborator

guardrex commented Aug 10, 2019

MOVED TO #12842 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

No branches or pull requests

5 participants