[en] Communication between 1:n clients (solved)

Topics: Technical Support
May 8, 2015 at 10:11 PM
Hi,

sorry about the issue, I looked in the forum and googled around, but did not find my anwser yet.

I'm looking for a communication service from one "server" programm to many clients. I tried the "MiniChat" but it didn't match my representation. This was very unstable and connection was broken after about 2 minutes.

My representations are:
I'd like to have a server "communication" running on given port xxxx. One ore more clients can conect to it and could send a request to the server. (not only string value, serialized input). The clients should send a response like an ebc-event or anything else to the sever and only this client gets an result for it. (Like an acknoldgement for the request to the server)

I could try to introduce place a guid or something other unique identic to the request, but perhaps there is another workaround about this.

if there's anybody involved with this, it would be very nice if you have a code sample for me, how to handle server and client site request.

Best regards.
Jens.
Coordinator
May 11, 2015 at 12:31 AM
Hi Jens,
 
I'm looking for a communication service from one "server"
programm to many clients. I tried the "MiniChat" but it didn't
match my representation. This was very unstable and connection
was broken after about 2 minutes.
 
That's very strange. Please be more specific.

How to reproduce this behavior? What was your usage scenario for MiniChat?
What were the symptoms of the lost connection?
MiniChat should have stable connection in any circumstances.
 
I'd like to have a server "communication" running on given port xxxx.
One ore more clients can conect to it and could send a request to the server.
(not only string value, serialized input). The clients should send a response
like an ebc-event or anything else to the sever and only this client gets an
result for it. (Like an acknoldgement for the request to the server)
 
I don't quite get it, sorry.

If a client sends a request to the server and then gets a result for it, then
it's a typical request-reply RPC call. Communication channel indeed uses Guids
to match requests with their replies, and you don't have to do it yourself.

If you need two-way asynchronous communication, like EBC, then every client
should also be a server. Every node gets its own ZyanComponentHost and a number
of ZyanConnection instances for every adjacent node.

Please describe your application in more details, and I'll try to sketch an
example code for you.

Regards, Alex.
May 11, 2015 at 8:06 AM
Hi Alex,

thank you for your fast reply and sorry for the confusing question.

I think the second type would be the right for my application (two-way asynchronous communication EBC)

I have a windows program running as a windows service on a separate machine which should act as server process. This programm should always hold the coummunication. One or more clients (from other machines) should be able to connect to the server machine, sending a request and getting a response from the server process.

I tried the MiniChat sample and modified a little bit. (I put the server part in the console application and connected with 2 client against the server. This worked. But after about 2-5 minutes the connection in the server part was broken. Perhaps i missed something??? I used the newest nuget package to build the project.)

I want the server only respond to the requesting client.

I hope this is not so confusing.

Thanks a lot.

Regards, Jens.
May 12, 2015 at 9:13 PM
Hi Alex,

i posted you the necessary information about the case on the discussion thread.
A little bit occured in my mind as a thought about this. It is possible to act the server like a web-server and the clients
place the request 1:1???


Another question a thought about was. Are you looking to put the zyan framework to Windows10IoT. I'm devoping a
network scanning solution, independent working with zyan and want to communicate with other processes to get a request and put the result.

So we want to put the "IoTThinClinet" in each sub-network to deliver the recovered items as LDAP, SSN-Request to Linux, WMI, SNMP, Network-Range-Scanning and other. and as whe thought about the costs, a little Raspberry with Windows 10 IoT is not as much as a virtual machine with a windows licence or a mini pc applicance.

perhaps you're interessting you we'll stay in touch.

Best Regards, Jens.


Coordinator
May 13, 2015 at 11:28 AM
Edited May 13, 2015 at 11:29 AM
Hi Jens,
 
I put the server part in the console application and connected with 2
client against the server. This worked. But after about 2-5 minutes the
connection in the server part was broken.
 
I don't see any problems with your setup.

Our own Zyan-based application server works just as you described:
a console server (or a service) with lots of connected clients.
When the server goes offline or restarts, clients silently reconnect and
continue they work as if nothing happened. It works out of the box.
 
I want the server only respond to the requesting client.
...
It is possible to act the server like a web-server and the clients
place the request 1:1???
 
If all you need is a request-reply pattern, then just stick to simple RPC:
use server methods returning values. No events, no delegates, only functions.

Your shared interfaces project will end up with something like this:
public interface IMyServer
{
   MyResult GetMyResult(int parameter1, string parameter2);
}

[Serializable]
public class MyResult
{
   public string Payload { get; set; }
}
To add asynchrony, I recommend using .NET 4.5 Tasks, i.e.:
var myResult = await Task.Run(() => proxy.GetMyResult(1, ""));
 
Are you looking to put the zyan framework to Windows10IoT. I'm devoping a
network scanning solution, independent working with zyan and want to
communicate with other processes to get a request and put the result.
 
It's quite a possible area of research for Zyan. But I have to say that I don't
have resources to spend on things I'm not going to use myself. If you're brave
enough to investigate it yourself — you're welcome to fork the project and try
it on your own. Of course, I'll help you with any guidance you need.
 
little Raspberry with Windows 10
 
Take in mind that a Raspberry with Linux+Mono onboard might probably work
right out of the box with no modifications in Zyan library. Of course,
I haven't had a chance to try it myself, but I think that Mono framework has
better chances to include all features needed for Zyan to work.

Microsoft has a bad habit of stripping off useful features (i.e. transparent
proxies, Remoting stack, etc.) from .NET framework when porting it to
mobile platforms. So I don't think that Windows 10 will be easy to support
anywhere except on desktop.

Regards, Alex
May 13, 2015 at 4:21 PM
Hi Alex

Thanks dir your fast reply. I think now i have everythink to get it to work. If i have some experience about raspberty and 10 iot i will let you know about.

Best Jens thanks again

Estoy en camino.

Am 13.05.2015 um 12:28 schrieb yallie <[email removed]>:

From: yallie

Hi Jens,

I put the server part in the console application and connected with 2
client against the server. This worked. But after about 2-5 minutes the
connection in the server part was broken.

I don't see any problems with your setup.

Our own Zyan-based application server works just as you described:
a console server (or a service) with lots of connected clients.
When the server goes offline or restarts, clients silently reconnect and
continue they work as if nothing happened. It works out of the box.

I want the server only respond to the requesting client.
...
It is possible to act the server like a web-server and the clients
place the request 1:1???

If all you need is a request-reply pattern, then just stick to simple RPC:
use server methods returning values. No events, no delegates, only functions.

Your shared interfaces project will end up with something like this:
public interface IMyServer
{
   MyResult GetMyResult(int parameter1, string parameter2);
}

[Serializable]
public class MyResult
{
   public string Payload { get; set; }
}
To add asynchrony, I recommend using .NET 4.5 Tasks, i.e.:
var myResult = await Task.Run(() => proxy.GetMyResult(1, ""));

Are you looking to put the zyan framework to Windows10IoT. I'm devoping a
network scanning solution, independent working with zyan and want to
communicate with other processes to get a request and put the result.

It's quite a possible area of research for Zyan. But I have to say that I don't
have resources to spent on things I'm not going to use myself. If you're brave
enough to investigate it yourself — you're welcome to fork the project and try
it on your own. Of course, I'll help you with any guidance you need.

little Raspberry with Windows 10

Take in mind that a Raspberry with Linux+Mono onboard might probably work
right out of the box with no modifications in Zyan library. Of course,
I haven't had a chance to try it myself, but I think that Mono framework has
better chances to include all features needed for Zyan to work.

Microsoft has a bad habit of stripping off useful features (i.e. transparent
proxies, Remoting stack, etc.) from .NET framework when porting it to
mobile platforms. So I don't think that Windows 10 will be easy to support
anywhere except on desktop.

Regards, Alex
May 13, 2015 at 8:18 PM
Hi Alex,

thanks again,

One last issue,

I decided to take the RPC way. Is it possible this way to send different responses to the zyan-server (like GetStatus, StartRequest, etc.) ???

Do you have a stable, robust short sample from client/server/remoteobject site of this or a link to it.

Thanks in advance.

Regards Jens.
Coordinator
May 14, 2015 at 11:10 AM
Edited May 14, 2015 at 11:11 AM
Hi Jens,
 
Is it possible this way to send different responses to the zyan-server (like GetStatus, StartRequest, etc.) ???
 
Zyan server hosts any number of components (i.e. server objects).
Each component has its interface with any number of methods, properties and events.
Client communicates with server by creating a proxy for an interface and calling its methods.

Looks like you're asking if an interface can have many different methods like GetStatus, StartRequest, etc?
The answer is yes, of course — a server component can have as many different methods as you like.

Can a server method return values of different types?
Yes, absolutely. The only restriction is that all parameter types and return values must be serializable.

Did I answer your question?
 
Do you have a stable, robust short sample from client/server/remoteobject site of this or a link to it.
 
I have a very simple example of a client-server application using IPC channel:
https://gist.github.com/yallie/6065750

It's a tiny single file (less than 100 lines of code) that compiles to single executable.
When you execute it for the first time, it starts the server.
On the second run and subsequent runs it starts the clients.

The example uses Ipc channel which only works on one machine.
Replace it with Tcp or TcpDuplex channel so it works across the network.

Here is another tiny example (~70 lines) which run on duplex tcp channel.
It demonstrates the usage of Disconnected and Reconnected events to handle network problems.
https://gist.github.com/yallie/437ea4c087725693e1c2

Hope it helps.

Regards, Alex
Marked as answer by yallie on 5/14/2015 at 4:36 AM
May 14, 2015 at 11:20 AM
Jo Alex , thanks.

This was exactly i was looking for.
Mann thanks and a Great father's Day for you

Regards Jens

Estoy en camino.

Am 14.05.2015 um 12:10 schrieb yallie <[email removed]>:

From: yallie

Hi Jens,

Is it possible this way to send different responses to the zyan-server (like GetStatus, StartRequest, etc.) ???

Zyan server hosts any number of components (i.e. server objects).
Each component has its interface with any number of methods, properties and events.
Client communicates with server by creating a proxy for an interface and calling its methods.

Looks like you're asking if an interface can have many different methods like GetStatus, StartRequest, etc?
The answer is yes, of course — a server component can have as many different methods as you like.

Can a server method return values of different types?
Yes, absolutely. The only restriction is that all parameter types and return values must be serializable.

Did I answer your question?

Do you have a stable, robust short sample from client/server/remoteobject site of this or a link to it.

I have a very simple example of a client-server application using IPC channel:
https://gist.github.com/yallie/6065750

It's a tiny single file (less than 100 lines of code) that compiles to single executable.
When you execute it for the first time, it starts the server.
On the second run and subsequent runs it starts the clients.

The example uses Ipc channel which only works on one machine.
Replace it with Tcp or TcpDuplex channel so it works across the network.

Here is another tiny example (~70 lines) which run on duplex tcp channel.
It demonstrates the usage of Disconnected and Reconnected events to handle network problems.

Hope it helps.

Regards, Alex