我尝试使用TCP双工通道使用Zyan Communication Framework设置简单的RPC客户端/服务器通信,但是当客户端尝试连接到服务器时,我一直收到相同的错误&#34 ;自消息加密后公钥已更改"。
我已在客户端和服务器中明确将加密设置为false,因此我无法查看该错误的原因。
出于演示目的,我已经设置了一个演示问题的示例
版本:
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();
}
}
}
答案 0 :(得分:1)
https://zyan.codeplex.com/discussions/453233
“您正在使用双工TCP通道在同一AppDomain中进行连接.TcpEx通道不支持此设计。
请使用IpcBinary频道或NullChannel在同一应用程序域内进行连接。“