Is it possible to add a second server channel to a code-first project?

HI,

I have an existing code-first Data Abstract sever I was wondering how I could setup additional ServerChannel’s? For instance an additional one that could incorporate SSL\TLS. This is what I am working with:

    public static int Main(string[] args)
    {            
        ApplicationServer server = new ApplicationServer("MyRODAServer");
        //
        // Some optional setup for your server:
        //

        // TLS
        //server.AutoCreateSelfSignedCertificate = true;                         // Create a certificate on first run
        //                                                                       // Self-signed certificates are rejected by default so additional code
        //                                                                       // might be needed client-side to properly handle them. Please refer to
        //                                                                       // https://docs.remotingsdk.com/Clients/Tasks/HandlingSelfSignedCertificates/
        //                                                                       // for more details
        //server.NetworkServer.UseTLS = true;                                    // Enable traffic encryption
        //server.NetworkServer.CertificateFileName = "</path/to/certificate>";   // Optionally, load certificate from file
        //server.NetworkServer.CertificateThumbprint = "XX XX XX ...";           // or load certificate with provided thumbprint from the system certificate store
        //server.NetworkServer.Certificate = <certificate instance>              // or load certificate from elsewhere and provide it directly

        server.NetworkServer.ServerChannel = new IpHttpServerChannel();
        server.NetworkServer.Port = 8099;
        server.NetworkServer.ServerMessages[0].Envelopes.Add(new RemObjects.SDK.AesEncryptionEnvelope(@"45454545"));
		
	server.Run(args);
     }

Please advise.

Hello

There are 2 different features - CodeFirst and Server Boilerplate code.
CodeFirst is a way of defining services, structures etc while Server Boilerplate is a way of defining the server infraastructure like server channels, messages etc. If you’ll take a look at tmplates shipped with RO SDK you’ll find RODL-based servers that also use the Server Boilerplate code.

Take a look at this topic: https://docs.remotingsdk.com/Servers/Concepts/ApplicationServerClassNet/

It describes the server app options you have and contains sample code for a custom server with second server channel (exactly what you need) as well as a way to provide custom GUI

Regards

Thanks for the clarification & the topic that is exactly what I needed.

After looking at the documentation it is unclear to me how to define an AES encryption envelope for the extended network server. In this sample. Could you please point me in the right direction. Thanks!

Custom Network Server

In the following code a NetworkServer that exposes an additional ServerChannel is defined:

[ServerInfrastructure]
public class ExtendedNetworkServer : NetworkServer
{
private IpHttpServerChannel _serverChannel;

protected override void InternalStart()
{
base.InternalStart();

   this._serverChannel = new IpHttpServerChannel();
   this._serverChannel.Port = this.Port + 1;

this._serverChannel.Dispatchers.AddRange(this.ServerMessages.Select(m =>
new MessageDispatcher(m.DefaultDispatcherName, m)));
this._serverChannel.Open();
}

protected override void InternalStop()
{
this._serverChannel.Close();
base.InternalStop();
}
}

Same ServerMessages collection is used for the second channel too. Because AesEncryptionEnvelope is attached to a message instance it will be used by both server channels.