Application Server Configuration
Remoting SDK for .NET provides a server configuration infrastructure that makes it easy to manage server application's network connectivity parameters.
This feature allows to set up the server connectivity parameters using external configuration file, so there is no need anymore to rebuild the server application to change the Server Channel port, its type (i.e. protocol), disable or enable ZeroConf support etc.
And of course the configured components can still be accessed via code and customized, if needed.
Network connectivity components and options that can be configured include server channel, one or more server messages, session manager, event sink, event queue manager, TLS, and ZeroConf support component.
ApplicationServer class now exposes a property named NetworkServerConfiguration of type RemObjects.SDK.Server.INetworkServerConfiguration
. It is up to the developer to load configuration from any external source (SQLite database, JSON file, some cloud service etc)
and to instantiate own implementation of this interface. Remoting SDK provides a default implementation of this interface that can be used as a starting point.
Note: Configuration is applied when the NetworkServer
property is first accessed. So in the code like
server.NetworkServer.ServerChannel = new IpHttpServerCahnnel();
server.NetworkServerConfiguration = ...custom config implementation...
custom configuration will be ignored.
Of course the same configuration changes can be done via directly setting server.NetworkServer
properties. The purpose of this feature is to provide a way to load configuration from external sources.
For example, one could load JSON file from a cloud storage, deserialize it into an instance of NetworkServerConfiguration
class and then use that instance as a configuration settings source.
Sample Code
In this sample a server app is configured to serve JSON message on port 8100.
This sample code below uses C# however the code is very simple and should be obvious for any other language.
static class Program
{
public static int Main(string[] args)
{
ApplicationServer server = new ApplicationServer("SampleServer");
var configuration = new NetworkServerConfiguration();
configuration.ServerMessages.Clear();
configuration.ServerMessages.Add(new ServerMessageConfiguration(ServerMessageType.JSON, 0, true, SoapMode.DocumentLiteral));
configuration.ServerChannel.Port = 8100;
server.NetworkServerConfiguration = configuration;
server.Run(args);
return 0;
}
}
Available Options
The INetworkServerConfiguration
interface exposes following properties:
Property | Description |
---|---|
ServerChannel | Provides server channel settings. By default Http server channel is used. |
Security | Provides settings for the TLS server channel protection. By default this protection is disabled. |
ServerMessages | Provides settings for one or more server messages. By default Binary message is used. |
SessionManager | Provides settings for the session manager. By default the in-memory session manager is used. |
ApiDispatcher | Provides settings for the HTTP Api dispatcher. By default this dispatcher is disabled. |
JavaScriptDispatcher | Provides settings for the Java Script dispatcher. By default this dispatcher is disabled. |
All settings providers are described in more details below.
ServerChannel
Provides settings needed to configure the server communication channel. Note that some of the options that can be defined in this section are not applicable to some of the available channel types. In case such option is provided it will be ignored, no exception will be raised at run-time.
Property | Type | Description |
---|---|---|
ChannelType | ServerChannelType enum | Type of the server channel. By default Http server channel is used. |
Port | Integer | Server port. Specifies port the server application will accept connections to. The default value is 8099. Not applicable to the NamedPipe server channel type. |
EnableZeroConf | Boolean | Defines whether the server application should register its services in the ZeroConf environment. Not applicable to the NamedPipe, SysHttp and SysSuperHttp server channel types. The default value is false |
SendCORSHeader | Boolean | Defines whether the server application should accept CORS requests. Applicable only to the Http, SuperHttp, SysHttp and SysSuperHttp server channel types. The default value is false |
NamedPipeServer | String | Specifies the name of the host running the server. This can be a host name or IP address on the local network, or ".", which indicates the local machine. Applicable only to the NamedPipe server channel type. The default value is . |
NamedPipePath | String | Defines the unique name of the server to use. The name must match the Path property specified on the Named Pipe client channel in the client application. Applicable only to the NamedPipe server channel type. The default value is DefaultServer |
Security
Provides settings needed to configure the optional TLS protection of the server's Server Channel.
Property | Type | Description |
---|---|---|
EnableTLS | Boolean | Defines whether the server app should apply TLS protection to its server channel. The default value if false. |
CertificateFileName | String | Defines full path to the certificate file. The file should contain a TLS certificate with both public and private keys stored without password. |
CertificateSubject | String | Used by the certificate watcher to auto-reload certificate from store in case it has been changed. |
CertificateThumbprint | String | Defines certificate thumbprint for certificates stored in the Certificate Store. |
Note: When both CertificateFileName and CertificateThumbprint are set, the certificate will be loaded from the CertificateFileName file.
ServerMessages
Provides server message settings.
Property | Type | Description |
---|---|---|
MessageType | ServerMessageType | Type of the server message. By default Bin message is used. |
MaxMessageSize | Integer | Defines maximal size of the Binary data stream that is accepted by the server. Setting this property to 0 or -1 will disable the message size check. The default value is 5242880. Applicable only to the Bin message type. |
SoapMode | SoapMode | Mode of the SOAP serializer/deserializer used to process client-server communications. Applicable only to the SOAP message type. The default value is DocumentLiteral. |
JsonWrapResult | Boolean | Defines whether the server operation should be wrapped into an object when the result is sent to the client application. For example an operation result would look like {result: 2} when wrapResult is set to false and{result: {Result:2}} when set to true. Applicable only to the JSON message type. The default value is false. Note: This option has to be set to true to allow JavaScript-based clients to consume server data. |
SessionManager
Provides settings needed to configure the Session Manager used by the server application.
Property | Type | Description |
---|---|---|
ManagerType | SessionManagerType | Type of the session manager used. By default the In-Memory session manager is used. |
Timeout | Integer | Session timeout is seconds. Applicable only to the Memory session manager. The default value is 600. |
OlympiaApplicationId | Guid | Application Id used by the Olympia Server server to prevent the server application from accessing session data that doesn't belong to it. Applicable only to the Olympia session manager. |
OlympiaHost | String | Hostname or IP address of the Olympia Server instance. Applicable only to the Olympia session manager. The default value is 127.0.0.1. |
OlympiaPort | Integer | Port used bt the Olympia Server instance. Applicable only to the Olympia session manager. The default value is 8011. |
ApiDispatcher
Provides HttpAPI Dispatcher settings.
Please note that this Dispatcher can be enabled only on Http-based channels.
Property | Type | Description |
---|---|---|
Enabled | Boolean | Flag indicating whether HttpAPI Dispatcher itself should be enabled or not. The default value is false. |
Host | String | Server host name used in the server API meta-information. The default value is an empty string so this entry is omitted in the resulting OpenAPI definition. |
Path | String | Root path for HttpAPI calls. The default value is /api. |
Name | String | Server API name used in the server API meta-information. The default value is an empty string so default server name is used. |
Version | String | Server API version used in the server API meta-information. The default value is an empty string so default "1.0.0" value is used. |
JavaScriptDispatcher
Provides JavaScript Dispatcher settings.
Please note that JavaScript Dispatcher can be enabled only on Http-based channels.
Property | Type | Description |
---|---|---|
Enabled | Boolean | Flag indicating whether JavaScript Dispatcher itself should be enabled or not. The default value is false. |
DefaultFile | String | Name of the file that is sent to the client when it tries to list folder contents (i.e. tries to access the server without providing requested file name). The default value is index.html. |
Path | String | Path that should be used to access resources exposed by the JavaScript Dispatcher. The default value is /js/. |
ServeFiles | Boolean | Flag indicating whether JavaScript Dispatcher should provide access to a physical folder. The default value is false. |
Folder | String | Name of the folder used to provide resources to the JavaScript Dispatcher in case the ServeFiles is set to true. The default value is html. |
ServeROJS | Boolean | Flag indicating whether JavaScript Dispatcher should provide access to the Remoting SDK for JavaScript scripts. The default value is true. |
Summary
The Server Configuration provides an easy way to manage server application's network connectivity parameters via external configuration source and to change them if needed without rebuilding the server application itself.