Question

i'm trying to write a small chat server using .Net Remoting in C#. The connection to the Server from the client works nicely, but as soon as i try to "broadcast" a sent message to all other clients (or even the same client), the server throws an exception.

"Der Remoteproxy hat keine Channelsenke, d. h., der Server besitzt keine registrierten Serverchannel oder die Anwendung hat keinen passenden Clientchannel, um mit dem Server zu kommunizieren."

what translates to

"This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server."

How would i change this?

Here ( https://www.dropbox.com/s/y40cdv3lopsf6d7/Chatprojekt.zip ) you can find a copy of the full project, but to help others who have the same problem, i'll explain what i did.

On the server i opened a TcpChannel on a specific port, made an interface for both,the server and the client. I connect to the server and with a method,i pass the client instance to the server. Both implementations of the interfaces implement MarshalByRefObj to use Proxies for method invokation.

Thanks already a lot for helping me

Was it helpful?

Solution

I gave up on doing real .NET remoting in favor of WCF a long time ago. Recently I've been using RemotingLite and my own variant of it which also supports named pipes called DuoVia.Net. You simply write your interface contract and DTO's, share those in an assembly on client and server and write your implementation on the server side.

No client to produce. These libraries produce their own through reflection and dynamic assembly generation by emitting IL. Cool stuff. Have a look at how easy the client side is:

class Program
{
    static void Main(string[] args)
    {
        var sw = Stopwatch.StartNew();
        var ipEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8098);

        var from = 0;
        var to = 500;
        Parallel.For(from, to, index =>
        {
            using (var client = new NetTcpTesterProxy(ipEndpoint))
            {
                var id = client.GetId("test1", 3.314, 42);
                var response = client.Get(id, "mirror", 4.123, 42);
                var list = client.GetItems(id);
            }
        });
        sw.Stop();
        var msperop = sw.ElapsedMilliseconds / 1500.0;
        Console.WriteLine("tcp: {0}, {1}", sw.ElapsedMilliseconds, msperop);

        Thread.Sleep(5000);

        var pipeName = "DuoViaTestHost";
        sw = Stopwatch.StartNew();
        Parallel.For(from, to, index =>
        {
            using (var client = new NetNpTesterProxy(new NpEndPoint(pipeName)))
            {
                var id = client.GetId("test1", 3.314, 42);
                var response = client.Get(id, "mirror", 4.123, 42);
                var list = client.GetItems(id);
            }
        });
        sw.Stop();
        msperop = sw.ElapsedMilliseconds / 1500.0;
        Console.WriteLine("pip: {0}, {1}", sw.ElapsedMilliseconds, msperop);

        Console.ReadLine();
    }
}

Have fun!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top