[en] Public key changed since the message was encrypted (solved)

Topics: Technical Support
Aug 13, 2013 at 5:12 AM
My client and server on the same WPF program.
I tried starting a separate thread
if (cs.IsServer)
              {
                  s_bShutDownServerThread = false;
                  s_serverThread = new Thread (ServerThread.Run);
                  s_serverThread.Start ();
             
            }
This is the start of the code
  var port = 1911;
             var protocol = new TcpDuplexServerProtocolSetup (port, employeeService, true);
             var host = new ZyanComponentHost ("ITJH", protocol);
             / / Enable client reconnection
     host.PollingEventTracingEnabled = true;

Here is the link code.
    try
                     {
                         conn = new ZyanConnection (BaseAddress + "/ ITJH", protocol, credentials, false, true);
                         conn.PollingEnabled = true;
                         conn.PollingInterval = TimeSpan.FromMinutes (1);
                         conn.Disconnected + = (s, e) => MessageBox.Show ("Link Host abnormal program will be closed", "link host exception");
                     
                     }
Eventually throws an exception
Public key changed since the message was encrypted.

I used the same code in a single WPF program start this service. When there is no mistake. I am very puzzled.
Coordinator
Aug 13, 2013 at 6:53 AM
Hi,

you're using duplex TCP channel to connect within the same AppDomain.
TcpEx channel doesn't support this by design.

Please use either IpcBinary channel or NullChannel to connect within the same application domain.
Aug 13, 2013 at 7:29 AM
Likely to improve zyan achieve this support?
Coordinator
Aug 13, 2013 at 7:40 AM
No, this is by design.

Using encrypted duplex TCP channel within the same AppDomain makes no sense.
Please use another protocol for the in-process communication.

You can start several ZyanComponentHost instances with different protocols — one for IPC, another for duplex TCP.
Both component hosts can share the same ComponentCatalog, so ipc host publishes the same components as tcp host:
var tcpProtocol = new TcpDuplexServerProtocolSetup (port, employeeService, true); 
var tcpHost = new ZyanComponentHost ("ITJH", tcpProtocol); // for remote connections

var ipcProtocol = new IpcBinaryServerProtocolSetup("AnyPortName");
var ipcHost = new ZyanComponentHost("ITJHIpc", ipcProtocol, tcpHost.ComponentCatalog); // for local machine connections
Aug 13, 2013 at 7:48 AM
My goal is to make part of the client can be used directly. Do not go without care services, or start the service
In some cases serve only one customer.
Can I
System.AppDomain appDomain = System.AppDomain.CreateDomain ("ApplicationDomainTest");
Dynamically creates an AppDomain to achieve it?

Or cancel the encryption?
Aug 13, 2013 at 7:49 AM
Duplex communication system is very important for now I do not want to change him.
Aug 13, 2013 at 7:51 AM
I have a client that needs updating to notify his client update. What better solution do?
Thank you
Coordinator
Aug 13, 2013 at 8:03 AM
Edited Aug 13, 2013 at 8:04 AM
My goal is to make part of the client can be used directly. Do not go without care services, or start the service
In some cases serve only one customer.
 
I see, it makes sense when you have only one user and don't want to deploy a service.
What if you have several users? Will they all connect to a dedicated user as if it were server?
I'd not recommend doing that for several reasons.

First, the client that acts as a server will notice unexpected performance loss (especially if there are lot of other clients connected).
Second, if the client exits, all connected users will be disconnected unexpectedly.
So I'd recomment creating dedicated server.
 
Can I
System.AppDomain appDomain = System.AppDomain.CreateDomain ("ApplicationDomainTest");
Dynamically creates an AppDomain to achieve it?
 
Yes, creating a separate AppDomain dynamically would do the trick.
But I would prefer starting a separate ZyanComponentHost with IpcBinary protocol within the same process. It's much easier.
Coordinator
Aug 13, 2013 at 8:06 AM
Duplex communication system is very important for now I do not want to change him.
 
I don't suggest to change it.
I suggest to use two component hosts in parallel: one for duplex TCP connections, another for local IPC connections.
Please have a look at my code sample posted above.
Aug 13, 2013 at 8:12 AM
Understand what you mean. I think in the end what the program.
Did you say service suddenly shut down will bring some trouble.
Thank you for helping me to solve these problems and suggestions very grateful to you.
Coordinator
Aug 13, 2013 at 8:20 AM
Edited Aug 13, 2013 at 8:21 AM
Did you say service suddenly shut down will bring some trouble.
 
Not exactly. What I say is that client programs aren't used in the same way as server programs.
They are made for different purposes.

Client application is treated as something that belongs to the current user.
The user don't expect that he will be serving other users and he can quit application any time he wants.
So, client application serving another client applications is not a common practice.

On the contrary, server is meant to serve other applications.
Stopping server application implies much more serious consequences than stopping client application.
That said, separating client and server is usually a good idea.
Aug 13, 2013 at 8:24 AM
What is the real-time communication software can be linked to you with something?
Our computer sales in China to develop a company-specific management software, has more than 3,000 customers.
Has now been applied in most modules zyan develop new versions of the software.
It now appears that two-way communication is the way desktop software, he was able to achieve some of the more complex applications.
I hope you can get more help we can pay to hire you as our support for assistance.
I can provide a full set of source code because of lack of experience developing hope give us some guidance.
Coordinator
Aug 13, 2013 at 10:41 AM
Edited Aug 13, 2013 at 10:48 AM
What is the real-time communication software can be linked to you with something?
 
You can contact me via skype, user name yalgol.
I'll be glad to provide support as long as I have some free time.
Coordinator
Aug 21, 2013 at 7:15 AM
Hello youdontcay,

yallie is on vacation at the moment.
If you need further support, I'll answer you questions.

Regards,
Rainbird