Class WaveServer
Represents "(W)eb(A)pp(V)iew(E)nhanced" web server which provides DYNAMIC web site services.
This server is not meant to be exposed directly to the public Internet, rather it should be used as an application server
behind the reverse proxy, such as NGINX. This server is designed to serve dynamic data-driven requests/APIs and not meant to be used
for serving static content files (although it can).
The implementation is based on a lightweight HttpListener that processes incoming Http requests via an injectable WorkDispatcher
which governs the threading and WorkContext lifecycle.
The server processing pipeline is purposely designed to be synchronous-blocking (thread per call) which does not mean that the
server is inefficient, to the contrary - this server design is specifically targeting short-called methods relying on a classical thread call stack.
This approach obviates the need to create surrogate message loops/synchro contexts, tasks and other objects that introduce extra GC load.
The server easily support "dangling"(left open indefinitely) WorkContext instances that can stream events (i.e. SSE/Server Push) and WebSockets from
specially-purposed asynchronous notification threads.
Inheritance
System.Object
WaveServer
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Azos.Wave.dll
Syntax
public class WaveServer : DaemonWithInstrumentation<IApplicationComponent>, IDisposable, IDaemon, IDaemonView, IApplicationComponent, INamed, IConfigurable, ILocalizedTimeProvider, IInstrumentable, IExternallyParameterized
Constructors
WaveServer(IApplicationComponent)
Declaration
public WaveServer(IApplicationComponent director)
Parameters
WaveServer(IApplicationComponent, String)
Declaration
public WaveServer(IApplicationComponent director, string name)
Parameters
WaveServer(IApplication)
Declaration
public WaveServer(IApplication app)
Parameters
WaveServer(IApplication, String)
Declaration
public WaveServer(IApplication app, string name)
Parameters
Fields
ACCEPT_THREAD_GRANULARITY_MS
Declaration
public const int ACCEPT_THREAD_GRANULARITY_MS = 250
Field Value
Type |
Description |
System.Int32 |
|
CONFIG_DEFAULT_ERROR_HANDLER_SECTION
Declaration
public const string CONFIG_DEFAULT_ERROR_HANDLER_SECTION = "default-error-handler"
Field Value
Type |
Description |
System.String |
|
CONFIG_DISPATCHER_SECTION
Declaration
public const string CONFIG_DISPATCHER_SECTION = "dispatcher"
Field Value
Type |
Description |
System.String |
|
CONFIG_GATE_SECTION
Declaration
public const string CONFIG_GATE_SECTION = "gate"
Field Value
Type |
Description |
System.String |
|
CONFIG_PREFIX_SECTION
Declaration
public const string CONFIG_PREFIX_SECTION = "prefix"
Field Value
Type |
Description |
System.String |
|
CONFIG_SERVER_SECTION
Declaration
public const string CONFIG_SERVER_SECTION = "server"
Field Value
Type |
Description |
System.String |
|
DEFAULT_CLIENT_VARS_COOKIE_NAME
Declaration
public const string DEFAULT_CLIENT_VARS_COOKIE_NAME = "WV.CV"
Field Value
Type |
Description |
System.String |
|
DEFAULT_DRAIN_ENTITY_BODY_TIMEOUT_SEC
Declaration
public const ushort DEFAULT_DRAIN_ENTITY_BODY_TIMEOUT_SEC = 120
Field Value
Type |
Description |
System.UInt16 |
|
DEFAULT_ENTITY_BODY_TIMEOUT_SEC
Declaration
public const ushort DEFAULT_ENTITY_BODY_TIMEOUT_SEC = 120
Field Value
Type |
Description |
System.UInt16 |
|
Declaration
public const ushort DEFAULT_HEADER_WAIT_TIMEOUT_SEC = 120
Field Value
Type |
Description |
System.UInt16 |
|
DEFAULT_IDLE_CONNECTION_TIMEOUT_SEC
Declaration
public const ushort DEFAULT_IDLE_CONNECTION_TIMEOUT_SEC = 120
Field Value
Type |
Description |
System.UInt16 |
|
DEFAULT_KERNEL_HTTP_QUEUE_LIMIT
Declaration
public const int DEFAULT_KERNEL_HTTP_QUEUE_LIMIT = 1000
Field Value
Type |
Description |
System.Int32 |
|
DEFAULT_MIN_SEND_BYTES_PER_SECOND
Declaration
public const uint DEFAULT_MIN_SEND_BYTES_PER_SECOND = 150U
Field Value
Type |
Description |
System.UInt32 |
|
DEFAULT_PARALLEL_ACCEPTS
Declaration
public const int DEFAULT_PARALLEL_ACCEPTS = 64
Field Value
Type |
Description |
System.Int32 |
|
DEFAULT_PARALLEL_WORKS
Declaration
public const int DEFAULT_PARALLEL_WORKS = 256
Field Value
Type |
Description |
System.Int32 |
|
DEFAULT_REQUEST_QUEUE_TIMEOUT_SEC
Declaration
public const ushort DEFAULT_REQUEST_QUEUE_TIMEOUT_SEC = 120
Field Value
Type |
Description |
System.UInt16 |
|
INSTRUMENTATION_DUMP_PERIOD_MS
Declaration
public const int INSTRUMENTATION_DUMP_PERIOD_MS = 3377
Field Value
Type |
Description |
System.Int32 |
|
MAX_KERNEL_HTTP_QUEUE_LIMIT
Declaration
public const int MAX_KERNEL_HTTP_QUEUE_LIMIT = 524288
Field Value
Type |
Description |
System.Int32 |
|
MAX_PARALLEL_ACCEPTS
Declaration
public const int MAX_PARALLEL_ACCEPTS = 1024
Field Value
Type |
Description |
System.Int32 |
|
MAX_PARALLEL_WORKS
Declaration
public const int MAX_PARALLEL_WORKS = 1048576
Field Value
Type |
Description |
System.Int32 |
|
MIN_KERNEL_HTTP_QUEUE_LIMIT
Declaration
public const int MIN_KERNEL_HTTP_QUEUE_LIMIT = 16
Field Value
Type |
Description |
System.Int32 |
|
MIN_PARALLEL_ACCEPTS
Declaration
public const int MIN_PARALLEL_ACCEPTS = 1
Field Value
Type |
Description |
System.Int32 |
|
MIN_PARALLEL_WORKS
Declaration
public const int MIN_PARALLEL_WORKS = 1
Field Value
Type |
Description |
System.Int32 |
|
Properties
ClientVarsCookieName
Provides the name of cookie where server keeps client vars
Declaration
[Config]
[ExternalParameter(new string[]{"web"})]
public string ClientVarsCookieName { get; set; }
Property Value
Type |
Description |
System.String |
|
ComponentCommonName
Declaration
public override string ComponentCommonName { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
ComponentLogTopic
Declaration
public override string ComponentLogTopic { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
Dispatcher
Gets/sets work dispatcher
Declaration
public WorkDispatcher Dispatcher { get; set; }
Property Value
DrainEntityBodyTimeoutSec
Declaration
[Config(Default = (ushort)120)]
[ExternalParameter(new string[]{"web"})]
public ushort DrainEntityBodyTimeoutSec { get; set; }
Property Value
Type |
Description |
System.UInt16 |
|
EntityBodyTimeoutSec
Declaration
[Config(Default = (ushort)120)]
[ExternalParameter(new string[]{"web"})]
public ushort EntityBodyTimeoutSec { get; set; }
Property Value
Type |
Description |
System.UInt16 |
|
EnvironmentName
Provides the name of environment, i.e. DEV,PROD, TEST i.e. some handlers may depend on environment name to serve DEV vs PROD java script files etc.
Declaration
[Config]
public string EnvironmentName { get; set; }
Property Value
Type |
Description |
System.String |
|
Gate
Declaration
public INetGate Gate { get; set; }
Property Value
Declaration
[Config]
public string GateCallerRealIpAddressHeader { get; set; }
Property Value
Type |
Description |
System.String |
|
Declaration
[Config(Default = (ushort)120)]
[ExternalParameter(new string[]{"web"})]
public ushort HeaderWaitTimeoutSec { get; set; }
Property Value
Type |
Description |
System.UInt16 |
|
IdleConnectionTimeoutSec
Declaration
[Config(Default = (ushort)120)]
[ExternalParameter(new string[]{"web"})]
public ushort IdleConnectionTimeoutSec { get; set; }
Property Value
Type |
Description |
System.UInt16 |
|
IgnoreClientWriteErrors
When true does not throw exceptions on client channel write
Declaration
[Config(Default = true)]
public bool IgnoreClientWriteErrors { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
InstrumentationEnabled
When true, emits instrumentation messages
Declaration
[Config]
[ExternalParameter(new string[]{"web", "instrumentation"})]
public override bool InstrumentationEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Overrides
Azos.Apps.DaemonWithInstrumentation<Azos.Apps.IApplicationComponent>.InstrumentationEnabled
KernelHttpQueueLimit
Establishes HTTP.sys kernel queue limit
Declaration
[Config]
public int KernelHttpQueueLimit { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
LogHandleExceptionErrors
When true writes errors that get thrown in server cathc-all HandleException methods
Declaration
[Config]
[ExternalParameter(new string[]{"web", "instrumentation"})]
public bool LogHandleExceptionErrors { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
LogMatches
Returns matches used by the server's default error handler to determine whether exception details should be logged
Declaration
public OrderedRegistry<WorkMatch> LogMatches { get; }
Property Value
MinSendBytesPerSecond
Declaration
[Config(Default = 150U)]
[ExternalParameter(new string[]{"web"})]
public uint MinSendBytesPerSecond { get; set; }
Property Value
Type |
Description |
System.UInt32 |
|
ParallelAccepts
Specifies how many requests can get accepted from kernel queue in parallel
Declaration
[Config(Default = 64)]
public int ParallelAccepts { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
ParallelWorks
Specifies how many instances of WorkContext(or derivatives) can be processed at the same time
Declaration
[Config(Default = 256)]
public int ParallelWorks { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
Prefixes
Returns HttpListener prefixes such as "http://+:8080/"
Declaration
public IList<string> Prefixes { get; }
Property Value
Type |
Description |
System.Collections.Generic.IList<System.String> |
|
RequestQueueTimeoutSec
Declaration
[Config(Default = (ushort)120)]
[ExternalParameter(new string[]{"web"})]
public ushort RequestQueueTimeoutSec { get; set; }
Property Value
Type |
Description |
System.UInt16 |
|
Servers
Returns the global registry of all server instances that are active in this process
Declaration
public static IRegistry<WaveServer> Servers { get; }
Property Value
ShowDumpMatches
Returns matches used by the server's default error handler to determine whether exception details should be shown
Declaration
public OrderedRegistry<WorkMatch> ShowDumpMatches { get; }
Property Value
Methods
AfterListenerStart(HttpListener)
Override to set listener options such as TimeoutManager.MinSendBytesPerSecond after listener.Start()
Declaration
protected virtual void AfterListenerStart(HttpListener listener)
Parameters
Type |
Name |
Description |
System.Net.HttpListener |
listener |
|
BeforeListenerStart(HttpListener)
Override to set listener options such as TimeoutManager.MinSendBytesPerSecond before listener.Start()
Declaration
protected virtual void BeforeListenerStart(HttpListener listener)
Parameters
Type |
Name |
Description |
System.Net.HttpListener |
listener |
|
Declaration
protected override void DoConfigure(IConfigSectionNode node)
Parameters
Overrides
DoSignalStop()
Declaration
protected override void DoSignalStop()
Overrides
DoStart()
Declaration
protected override void DoStart()
Overrides
DoWaitForCompleteStop()
Declaration
protected override void DoWaitForCompleteStop()
Overrides
HandleException(WorkContext, WorkFilter, WorkHandler, Exception)
Handles processing exception by calling ErrorFilter.HandleException(work, error).
All parameters except ERROR can be null - which indicates error that happened during WorkContext dispose
Declaration
public virtual void HandleException(WorkContext work, WorkFilter filter, WorkHandler handler, Exception error)
Parameters
Log(MessageType, String, String, Exception, String, Nullable<Guid>)
Facilitates server logging
Declaration
public void Log(MessageType type, string text, string from = null, Exception error = null, string pars = null, Guid? related = default(Guid? ))
Parameters
Type |
Name |
Description |
MessageType |
type |
|
System.String |
text |
|
System.String |
from |
|
System.Exception |
error |
|
System.String |
pars |
|
System.Nullable<System.Guid> |
related |
|
MakeContext(HttpListenerContext)
Factory method that makes new WorkContext instances. Override to make a WorkContext-derivative
Declaration
protected virtual WorkContext MakeContext(HttpListenerContext listenerContext)
Parameters
Type |
Name |
Description |
System.Net.HttpListenerContext |
listenerContext |
|
Returns
Implements
System.IDisposable
Extension Methods