Remoting and missing channel sinks

前端 未结 3 471
旧巷少年郎
旧巷少年郎 2021-01-12 22:16

I ran into a remoting exception:

\"This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or

相关标签:
3条回答
  • 2021-01-12 22:51

    In order to use remoting across appdomains on objects derived from MarshalByRefObject it is necessary to create channels on both ends. Thus, you must create channels in each appdomain. There are efficient channels to do this locally on the same machine e.g. the IPC channel (uses named pipes).

    If the communication is "one-way", in the sense that only one of the sides is calling methods on proxies, you register a client channel here, and the server channel on the side which creates the objects.

    In case you need to go both ways, e.g. pass a logging object to the "server" in order to receive continuous log feedback, you must register a server channel at both ends, as the client suddenly also serves objects:

    class MyLogger : MarshalByRefObject
    {
        public Log(string text) { ... }
    }
    
    MyLogger logger = new MyLogger();
    proxyObj.LongRunningCommand(logger);
    
    0 讨论(0)
  • To expand on @RonCohen's answer -

    On the server, one typically creates a full channel the fun way (especially if you want to fix the TypeLevelFilter problem ala https://stackoverflow.com/a/9268223/344638):

    BinaryServerFormatterSinkProvider serverProvider;
    BinaryClientFormatterSinkProvider clientProvider;
    Hashtable properties = new Hashtable();
    
    serverProvider = new BinaryServerFormatterSinkProvider();
    serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
    
    clientProvider = new BinaryClientFormatterSinkProvider();
    
    properties.Add( "port", 8080 );
    
    this.chan = new TcpChannel( properties, clientProvider, serverProvider );
    
    ChannelServices.RegisterChannel( this.chan, true );
    

    Lets say you're using a sponsor on the client side. If you don't, and the client doesn't call the remoted object for a while, the server will drop the object:

    Object '/70c96e17_02a8_4e1a_a040_7b671b4a66b4/3fssua+asfozgeqqkrjql+4k_1.rem' has been disconnected or does not exist at the server.
    

    So you're using a sponsor, which the server then occasionally calls to renew the remoted object. But! Now the server has a remoted object - the sponsor gets remoted to the server side when the sponsor calls ILease.Register. But if the server doesn't have a remoting channel to the client, this fails.

    So, in the same way that the server has to expose a remoting channel to the client for the client to access remoted objects, the client has to expose a remoting channel to the server for the server to be able to access remoted objects like sponsors. In the end, both my client and server side end up having the same channel construction code (above), except I use different port numbers on each side.

    0 讨论(0)
  • 2021-01-12 23:15

    For those searching on the "This remoting proxy has no channel sink..." error, I got this error when calling a VB.NET COM wrapped Library from VBScript. All this was on the same Windows 7 machine so there should have been no client server issues. Eventually I worked out that the error was caused by me passing a load of arraylists filled with strings rather than filled with singles which is what the function I was calling was expecting. I don't understand why I got this error, but hopefully it might help someone getting this error.

    0 讨论(0)
提交回复
热议问题