2
我正在尝试使用TCP双工通道使用Zyan Communication Framework来设置简单的RPC客户端/服务器通信,但当客户端尝试连接时,我仍然收到相同的错误到服务器“由于消息被加密而改变了公钥”。Zyan Communication Framework - 公钥已更改,因为邮件被加密
我已经在客户端和服务器端明确地将加密设置为false,所以我看不到该错误的原因。
出于演示的目的,我已经安装了一个演示问题
版本:
- NET版本4.5.2
- Zyan 2.6.2
using System;
using System.Threading;
using Zyan.Communication;
using Zyan.Communication.Protocols.Tcp;
namespace StackOverflowMinimalSample
{
public interface ISampleService
{
string GetGreeting();
}
public class SampleService : ISampleService
{
public string GetGreeting()
{
return "Hello World";
}
}
class Program
{
static void Main(string[] args)
{
int port = 5252;
Thread serverThread = new Thread(() =>
{
var protocol = new TcpDuplexServerProtocolSetup(port){Encryption = false};
using (var tcpHost = new ZyanComponentHost("TCPCommunication", protocol))
{
tcpHost.RegisterComponent<ISampleService, SampleService>();
Console.WriteLine("Press [Enter] to exit");
Console.ReadLine();
}
})
{IsBackground = true};
serverThread.Start();
Thread clientThread = new Thread(() =>
{
// Sleep for a while to give time to the server
Thread.Sleep(5000);
var protocol = new TcpDuplexClientProtocolSetup(encryption: false);
var url = protocol.FormatUrl("127.0.0.1", port, "TCPCommunication");
try
{
using (var connection = new ZyanConnection(url))
{
ISampleService proxy = connection.CreateProxy<ISampleService>();
string serverMessage = proxy.GetGreeting();
Console.WriteLine("Server message: " + serverMessage);
}
}
catch (Exception e)
{
// This will throw here.
Console.WriteLine("Exception caught: " + e.Message);
}
})
{IsBackground = true};
clientThread.Start();
Console.WriteLine("Press [Enter] to exit");
Console.ReadLine();
}
}
}