Exemple #1
0
        static async Task SslTest()
        {
            var x509Cert = GetXeenyTestCertificate(out string certName);

            var tcpAddress = $"tcp://localhost:9999/tcpTest";

            var host = new ServiceHostBuilder <Service>(InstanceMode.PerConnection)
                       .AddTcpServer(tcpAddress, options =>
            {
                options.SecuritySettings = SecuritySettings.CreateForServer(x509Cert);
                options.FramingProtocol  = FramingProtocol.ConcurrentFragments;
            })
                       .WithConsoleLogger(LogLevel.None)
                       .CreateHost();
            await host.Open();

            var client = await new ConnectionBuilder <IService>()
                         .WithTcpTransport(tcpAddress, options =>
            {
                options.SecuritySettings = SecuritySettings.CreateForClient(certName);
                options.FramingProtocol  = FramingProtocol.ConcurrentFragments;
            })
                         .WithConsoleLogger(LogLevel.None)
                         .CreateConnection();

            var msg = await client.Echo("test");

            Console.WriteLine(msg);

            await host.Close();

            ((IConnection)client).Close();

            Console.WriteLine("Test Done!");
        }
Exemple #2
0
        static async Task Debug()
        {
            var tcpAddress = $"tcp://localhost:9999/tcpTest";

            var host = new ServiceHostBuilder <Service>(InstanceMode.PerConnection)
                       .AddTcpServer(tcpAddress, options =>
            {
                options.ReceiveBufferSize = 40;
                options.ReceiveTimeout    = TimeSpan.FromMinutes(60);
                options.Timeout           = TimeSpan.FromMinutes(60);
                options.FramingProtocol   = FramingProtocol.ConcurrentFragments;
            })
                       .WithConsoleLogger(LogLevel.Trace)
                       .CreateHost();
            await host.Open();

            var client = await new ConnectionBuilder <IService>()
                         .WithTcpTransport(tcpAddress, options =>
            {
                options.SendBufferSize    = 45;
                options.KeepAliveInterval = TimeSpan.FromMinutes(50);
                options.ReceiveTimeout    = TimeSpan.FromMinutes(60);
                options.Timeout           = TimeSpan.FromMinutes(60);
                options.FramingProtocol   = FramingProtocol.ConcurrentFragments;
            })
                         .WithConsoleLogger(LogLevel.None)
                         .CreateConnection();

            var msg = await client.Echo("test");

            Console.WriteLine(msg);

            await host.Close();

            ((IConnection)client).Close();

            Console.WriteLine("Test Done!");
        }