Giter VIP home page Giter VIP logo

kestrel-linux-transport's Introduction

This code is no longer maintained, and won't be updated for new versions of .NET.

Introduction

The ASP.NET Core Kestrel webserver has been using libuv as a cross-platform network library. It is possible to replace libuv with another implementation thanks to the Transport abstraction.

In this repo we explore creating a Transport for Linux specifically.

Using the package

Add the myget feed to your NuGet.Config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="rh" value="https://www.myget.org/F/redhat-dotnet/api/v3/index.json" />
  </packageSources>
</configuration>

Include a package reference in your project csproj file:

  <ItemGroup>
    <PackageReference Include="RedHat.AspNetCore.Server.Kestrel.Transport.Linux" Version="3.1.0-*" />
  </ItemGroup>

Call UseLinuxTransport when creating the WebHost in your Program.cs:

public static IWebHost BuildWebHost(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder
                        .UseLinuxTransport()
                        .UseStartup<Startup>();
                });

note: It's safe to call UseLinuxTransport on non-Linux platforms, it will no-op.

Repo structure

There are 5 projects in this repository:

  • src/RedHat.AspNetCore.Server.Kestrel.Transport.Linux: managed library implementing Transport
  • samples/KestrelSample: Kestrel app for benchmarking
  • test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test: xunit test projects, has access to internals of managed library
  • test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TestApp: empty application to use during development, has access to internals of managed library

The library can be packaged by running the dotnet pack on src/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.

$ dotnet pack src/RedHat.AspNetCore.Server.Kestrel.Transport.Linux --configuration Release

To build the library and run the tests execute dotnet test on test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test.

$ dotnet test test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test

Design

Similar to other implementations, this library makes use of the non-blocking socket and epoll. Like the corefx Socket implementation, the eventloop is implemented in managed (C#) code. This is different from the libuv loop which is part of the native libuv library.

This library does not provide a generic xplat network API. It uses the kernel primitives directly to implement the Transport API. This reduces the number of heap allocated objects (e.g. uv_buf_t, SocketAsyncEventArgs), which means there is less GC pressure. Implementations building on top of an xplat API will pool objects to achieve this.

The implementation starts a number of threads that each accept connections. This is based on SO_REUSEPORT socket option. This option allow multiple sockets to concurrently bind and listen to the same port. The kernel performs load-balancing between the listen sockets.

The Transport has these options:

  • DeferSend: This defers sends to the Transport Thread which increases chances for multiple sends to coalesce. This options defaults to true.

  • ThreadCount: Specifies the number of Transport Threads. This defaults to the number of logical processors in the system, maxed to 16.

  • AioSend/AioReceive: Uses Linux AIO system calls to batch send and receive calls. AioSend implies DeferSend. These options default to true.

kestrel-linux-transport's People

Contributors

halter73 avatar lillo42 avatar tmds avatar zcsizmadia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kestrel-linux-transport's Issues

Getting Method Not Found Error

<Method not found: 'Void Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.IConnectionDispatcher.OnConnection(Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.TransportConnection)'.
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.HandleAccept(TSocket tacceptSocket)
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Run()
FailFast:
TransportThread

at System.Environment.FailFast(System.String, System.Exception)
at System.Environment.FailFast(System.String, System.Exception)
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread+ThreadContext.Run()
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.PollThread(System.Object)
at System.Threading.Thread.ThreadMain_ParameterizedThreadStart(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)

Exception details:
System.MissingMethodException: Method not found: 'Void Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.IConnectionDispatcher.OnConnection(Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.TransportConnection)'.
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.HandleAccept(TSocket tacceptSocket)
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Run()>

StopDisconnectsClient(waitForAccept: False) failed in CI

In #89:

A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:01.5867643]     Tests.AioTransportTests.StopDisconnectsClient(waitForAccept: False) [FAIL]
Test run in progress.  X Tests.AioTransportTests.StopDisconnectsClient(waitForAccept: False) [3ms]
  Error Message:
   Assert.NotNull() Failure
  Stack Trace:
     at Tests.TransportTestsBase.StopDisconnectsClient(Boolean waitForAccept) in /home/travis/build/redhat-developer/kestrel-linux-transport/test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test/TransportTests.cs:line 125

Getting Method Not Found Error

I am trying to use linux transport, Here are the details:
Platform: kestrel server with reverse proxy on Ubuntu 16.04
Program.cs
<return WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(builder => builder.AddFile(options =>
{
options.FileName = "diagnostics-"; // The log file prefixes
options.LogDirectory = "LogFiles"; // The directory to write the logs
options.FileSizeLimit = 20 * 1024 * 1024; // The maximum log file size (20MB here)
options.Extension = "txt"; // The log file extension
}))
.UseLinuxTransport()
.UseStartup();>
ERROR:
<Method not found: 'Void Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.IConnectionDispatcher.OnConnection(Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.TransportConnection)'.
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.HandleAccept(TSocket tacceptSocket)
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Run()
FailFast:
TransportThread

at System.Environment.FailFast(System.String, System.Exception)
at System.Environment.FailFast(System.String, System.Exception)
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread+ThreadContext.Run()
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.PollThread(System.Object)
at System.Threading.Thread.ThreadMain_ParameterizedThreadStart(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)

Exception details:
System.MissingMethodException: Method not found: 'Void Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.IConnectionDispatcher.OnConnection(Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.TransportConnection)'.
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.HandleAccept(TSocket tacceptSocket)
at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Run()

Index outside of bounds after long-term usage

Had this happen twice on a production deployment that handles thousands of requests per second, only after several days of uptime. If it helps at all, I was also hitting a limit of open file handles a few times after switching to linux transport. Not certain if leak or just high usage (was exceeding 1mil where my app is usually around 180k) but I do plan on investigating that further.

Process terminated. TransportThread
   at System.Environment.FailFast(System.String, System.Exception)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread+ThreadContext.Run()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.PollThread(System.Object)
   at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart(System.Object)
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.AioSend(List`1 sendQueue)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.DoScheduledWork(Boolean aioSend)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Run()Process terminated. TransportThread
   at System.Environment.FailFast(System.String, System.Exception)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread+ThreadContext.Run()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.PollThread(System.Object)
   at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart(System.Object)
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.AioSend(List`1 sendQueue)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.DoScheduledWork(Boolean aioSend)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Run()Process terminated. TransportThread
   at System.Environment.FailFast(System.String, System.Exception)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread+ThreadContext.Run()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.PollThread(System.Object)
   at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart(System.Object)
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.AioSend(List`1 sendQueue)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.DoScheduledWork(Boolean aioSend)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Run()Process terminated. TransportThread
   at System.Environment.FailFast(System.String, System.Exception)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread+ThreadContext.Run()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.PollThread(System.Object)
   at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)

netstandard library problem

Dear Sirs,

I have following problem:
In our app we have WebHost in separated netstandard2.0 library by design. Could you please add netstandard2.0 as additional TargetFramework please?

2.1.0-preview1 - exception on exit

I just tried the Linux Transport, and seems to be working pretty well. I haven't noticed any issues so far serving content out of kestrel over https - nice work!

However, I often see the following exception when killing the kestrel instance via ctl-c:

crit: Microsoft.AspNetCore.Server.Kestrel[0]
      Unexpected exception in HttpConnection.ProcessRequestsAsync.
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'MemoryPoolBlock'.
   at System.Buffers.ThrowHelper.ThrowObjectDisposedException(ExceptionArgument argument)
   at System.Buffers.MemoryPoolBlock.Dispose()
   at System.IO.Pipelines.BufferSegment.ResetMemory()
   at System.IO.Pipelines.Pipe.CompletePipe()
   at System.IO.Pipelines.Pipe.CompleteWriter(Exception exception)
   at System.IO.Pipelines.Pipe.DefaultPipeWriter.Complete(Exception exception)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal.AdaptedPipeline.ReadInputAsync(Stream stream)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal.AdaptedPipeline.RunAsync(Stream stream)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.HttpConnection.ProcessRequestsAsync[TContext](IHttpApplication`1 httpApplication)

This sometimes is emitted multiple times as part of the same process being killed.

Here is the output of dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.302
 Commit:    9048955601

Runtime Environment:
 OS Name:     fedora
 OS Version:  28
 OS Platform: Linux
 RID:         fedora.28-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.302/

Host (useful for support):
  Version: 2.1.2
  Commit:  811c3ce6c0

.NET Core SDKs installed:
  2.1.302 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0-preview2-final [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Thanks

localhost + Docker development problem to bind IPv6 and IPv4 - throw IOException

Hi,

I'm trying to use ASP.NET Core with Linux Transport fail but when I run my project, ASP.NET Core fail to start:

project.zip

Call Stack:

      Unable to start Kestrel.
System.IO.IOException: EADDRNOTAVAIL
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.PosixResult.ThrowException()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.TSocket.Bind(IPEndPointStruct endpoint)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.CreateAcceptSocket(IPEndPoint endPoint, SocketFlags flags)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Start()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Run()
--- End of stack trace from previous location where exception was thrown ---
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Transport.BindAsync()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Transport.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.LocalhostListenOptions.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)

Full call stack:

root@d24828eef097:/workspaces/WebAppLinux2# dotnet run
Using launch settings from /workspaces/WebAppLinux2/Properties/launchSettings.json...
: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
      Creating key {10ca567a-54dd-44d7-8e26-e7847585a08c} with creation date 2019-10-11 06:44:21Z, activation date 2019-10-11 06:44:21Z, and expiration date 2020-01-09 06:44:21Z.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {10ca567a-54dd-44d7-8e26-e7847585a08c} may be persisted to storage in unencrypted form.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
      Writing data to file '/root/.aspnet/DataProtection-Keys/key-10ca567a-54dd-44d7-8e26-e7847585a08c.xml'.
dbug: RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Transport[0]
      BindAsync https://127.0.0.1:5001: TC:4 TA:False IC:False DA:False
dbug: RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Transport[0]
      BindAsync https://[::1]:5001: TC:4 TA:False IC:False DA:False
crit: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to start Kestrel.
System.IO.IOException: EADDRNOTAVAIL
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.PosixResult.ThrowException()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.TSocket.Bind(IPEndPointStruct endpoint)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.CreateAcceptSocket(IPEndPoint endPoint, SocketFlags flags)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Start()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Run()
--- End of stack trace from previous location where exception was thrown ---
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Transport.BindAsync()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Transport.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.LocalhostListenOptions.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)
dbug: RedHat.TransportThread.3[0]
      Stats A/AE:0/0 RE:0 WE:0 ZCS/ZCC:0/0
dbug: RedHat.TransportThread.2[0]
      Stats A/AE:0/0 RE:0 WE:0 ZCS/ZCC:0/0
dbug: RedHat.TransportThread.4[0]
      Stats A/AE:0/0 RE:0 WE:0 ZCS/ZCC:0/0
dbug: RedHat.TransportThread.1[0]
      Stats A/AE:0/0 RE:0 WE:0 ZCS/ZCC:0/0

Unhandled Exception: System.IO.IOException: EADDRNOTAVAIL
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.PosixResult.ThrowException()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.TSocket.Bind(IPEndPointStruct endpoint)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.CreateAcceptSocket(IPEndPoint endPoint, SocketFlags flags)
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Start()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.TransportThread.ThreadContext.Run()
--- End of stack trace from previous location where exception was thrown ---
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Transport.BindAsync()
   at RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Transport.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.LocalhostListenOptions.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.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at WebAppLinux2.Program.Main(String[] args) in /workspaces/WebAppLinux2/Program.cs:line 17

Dotnet core 3.0 custom packages are setup differently

Could find where to put Nuget.Config and no such place seems left for dotnet core 3.0. So custom packages add added with

dotnet add package RedHat.AspNetCore.Server.Kestrel.Transport.Linux -s https://www.myget.org/F/redhat-dotnet/api/v3/index.json

None of them support 3.0 yet.. -Has the changes merged into the regular Socket-variant. It's a lot faster now anyways.

info : Restoring packages for .......
info : GET https://api.nuget.org/v3-flatcontainer/redhat.aspnetcore.server.kestrel.transport.linux/index.json
info : GET https://www.myget.org/F/redhat-dotnet/api/v3/flatcontainer/redhat.aspnetcore.server.kestrel.transport.linux/index.json
info : OK https://www.myget.org/F/redhat-dotnet/api/v3/flatcontainer/redhat.aspnetcore.server.kestrel.transport.linux/index.json 57ms
info : NotFound https://api.nuget.org/v3-flatcontainer/redhat.aspnetcore.server.kestrel.transport.linux/index.json 489ms
error: Unable to find a stable package RedHat.AspNetCore.Server.Kestrel.Transport.Linux with version
error: - Found 456 version(s) in https://www.myget.org/F/redhat-dotnet/api/v3/index.json [ Nearest version: 3.0.0-191007-1144 ]
error: - Found 0 version(s) in Microsoft Visual Studio Offline Packages
error: - Found 0 version(s) in nuget.org
error: Package 'RedHat.AspNetCore.Server.Kestrel.Transport.Linux' is incompatible with 'all' frameworks in project

dotnet 5 support info

Is this kestrel transport supported for dotnet 5 based aspnet core
If not, could you please state this somewhere in the docs?

Bedrock refactoring

With #80 the initial implementation of bedrock abstractions is:

public class LinuxTransportFactory : IConnectionListenerFactory
{
    LinuxTransport(IOptions<LinuxTransportOptions> options);
}
internal Transport : IConnectionListener {}

DI injection:
services.AddSingleton<IConnectionListenerFactory, LinuxTransportFactory>();

This comes from the previous abstraction, which only allowed a transport to handle in-coming connections.

We should add support for out-coing connections (IConnectionFactory) and allow re-using the TransportThreads between IConnectionFactory and IConnectionListenerFactory.

This would look like:

public class LinuxTransport: IConnectionListenerFactory, IConnectionFactory, IAsyncDisposable
{
    LinuxTransport(IOptions<LinuxTransportOptions> options);
    DisposeAsync(); // controls life-time of memorypool, transport threads, ...
}
internal ConnectionFactory : IConnectionFactory
{
public ConnectionFactory(LinuxTransport transport) {}
ConnectAsync(...) => _transport.ConnectAsync(...);
}
internal ConnectionListenerFactory : IConnectionListenerFactory
{
public ConnectionListenerFactory(LinuxTransport transport) {}
BindAsync(...) => _transport.BindAsync(...);
}

DI injection:
services.AddSingleton<LinuxTransport>();
services.AddSingleton<IConnectionFactory, ConnectionFactory>();
services.AddSingleton<IConnectionListenerFactory, ConnectionListenerFactory>();

@halter73 @davidfowl fyi

Unpin receive buffer MemoryHandles before flushing

When using this transport with DiagnosticMemoryPool, I observed the following error:

warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Connection processing ended abnormally.
System.InvalidOperationException: Can't release when reference count is already zero
   at System.Buffers.ThrowHelper.ThrowInvalidOperationException_ReturningPinnedBlock() in /home/shalter/.nuget/packages/microsoft.extensions.buffers.sources/2.1.1/contentFiles/cs/netstandard1.0/Microsoft.Extensions.Buffers.Sources/PipelinesThrowHelper.cs:line 41
   at System.Buffers.MemoryPoolBlock.Dispose(Boolean disposing) in /home/shalter/.nuget/packages/microsoft.extensions.buffers.sources/2.1.1/contentFiles/cs/netstandard1.0/Microsoft.Extensions.Buffers.Sources/MemoryPoolBlock.Debug.cs:line 81
   at System.Buffers.MemoryManager`1.System.IDisposable.Dispose()
   at System.IO.Pipelines.BufferSegment.ResetMemory()
   at System.IO.Pipelines.Pipe.AdvanceReader(BufferSegment consumedSegment, Int32 consumedIndex, BufferSegment examinedSegment, Int32 examinedIndex)
   at System.IO.Pipelines.Pipe.DefaultPipeReader.AdvanceTo(SequencePosition consumed, SequencePosition examined)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TryParseRequest(ReadResult result, Boolean& endConnection) in /home/shalter/aspnet/KestrelHttpServer/src/Kestrel.Core/Internal/Http/Http1Connection.cs:line 484
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application) in /home/shalter/aspnet/KestrelHttpServer/src/Kestrel.Core/Internal/Http/HttpProtocol.cs:line 519
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync[TContext](IHttpApplication`1 application) in /home/shalter/aspnet/KestrelHttpServer/src/Kestrel.Core/Internal/Http/HttpProtocol.cs:line 455

This appears to be happening because the Input PipeWriter is flushed before the corresponding MemoryHandles are disposed.

Travis hang without info

Travis can fail even without printing the long-running tests:

$ pushd test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test && dotnet restore && dotnet test && popd
~/build/redhat-developer/kestrel-linux-transport/test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test ~/build/redhat-developer/kestrel-linux-transport
pleted in 15.3 ms for /home/travis/build/redhat-developer/kestrel-linux-transport/src/RedHat.AspNetCore.Server.Kestrel.Transport.Linux/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.csproj.
  Restore completed in 7.66 sec for /home/travis/build/redhat-developer/kestrel-linux-transport/test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test.csproj.
  Restore completed in 8.34 sec for /home/travis/build/redhat-developer/kestrel-linux-transport/test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test.csproj.
e/travis/build/redhat-developer/kestrel-linux-transport/test/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test/bin/Debug/netcoreapp3.0/RedHat.AspNetCore.Server.Kestrel.Transport.Linux.Test.dll(.NETCoreApp,Version=v3.0)
Microsoft (R) Test Execution Command Line Tool Version 16.1.1
Copyright (c) Microsoft Corporation.  All rights reserved.
Starting test execution, please wait...
No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received
The build has been terminated

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.