Re: Server-to-Server Remoting

From: Allen Anderson (allen_at_sparkysystems.com)
Date: 04/15/04


Date: Thu, 15 Apr 2004 11:10:24 -0600

Your asking a lot of questions here so let me put down some general
notes based on what I've seen looking through your sample and
comments. You can't send an object from server b that you got at
server a and send it to client c. In other words, you can't middleman
an object.

the register channel code to get from server a to server b is
unncessary as your making a client call and there is already a channel
registered for the application because its serving another object.

your code that connects to server b from server a will be identical
except for the channel registrations.

to get around the problem with the type already being known locally,
stop using configuration files. I realize that most people recommend
using configuration files for everything, but this is a good time not
to. If you simply have your abstract class available and use
activator to get the type that YOU want to create at any given time,
then you will know that your are getting the type you want based on
the URI you use with activator.

Allen Anderson
http://www.glacialcomponents.com
mailto: allen@put my website url here.com

On 15 Apr 2004 02:12:00 -0700, bob@digitalmediums.com (Bob Pulgino)
wrote:

>Here's my situation:
>
>I have a classic client/server application that involves multiple
>users of a WinForms application connecting to a central remoted .NET
>component for business logic and database services. This has been
>working fine for a few months now. In fact, it is in production for
>two organizations; each organization has its own group of WinForms-app
>users and a unique server with the .NET component running to provide
>the users within that organization with services for the
>organization's unique database.
>
>I am trying to implement a new feature for the next release of this
>system that requires the ability to pass information from one
>organization's service component to another's; i.e., I need to be able
>to call a method on one specific instance of my remoted .NET component
>(for organization "A") from within another method of a different
>instance (server) of that same component (for organization "B").
>
>My problem is that I can't figure out how to register and instantiate
>the proxy for the remote component class from within the local
>instance of the same class - when I use the same code I used to
>connect from the WinForm application, the framework throws an "Unknown
>remoting error" exception the first time I reference the proxy.
>
>Here are the implementation details: I define an abstract base class
>called BaseDataService that is used by the client as the interface for
>the service component, which is a subclass of BaseDataService called
>MaxDataService.
>
>Here is the code I use in the console app that hosts the service
>component:
>
> RemotingConfiguration.Configure("MaxDataServiceConsole.exe.config")
>
>(...from MaxDataServiceConsole.exe.config:)
> <channels>
> <channel ref="http" port="1234">
> <serverProviders>
> <formatter ref="binary" />
> </serverProviders>
> </channel>
> </channels>
> <service>
> <wellknown
> mode="Singleton"
> type="DataServices.MaxDataService, MaxDataService"
> objectUri="MaxDataService.rem"
> />
> </service>
>
>
>Here is the code I used to connect to the service component from
>within the WinForms app:
>
> Private Shared mDataService As BaseDataService
> ...
> Dim channel As HttpChannel
> channel = New HttpChannel(Nothing, New
>BinaryClientFormatterSinkProvider(), Nothing)
> ChannelServices.RegisterChannel(channel)
> Dim serviceUrl as String =
>"http://localhost:1234/MaxDataService.rem"
> mDataService = CType(Activator.GetObject(GetType(BaseDataService),
>serviceUrl), BaseDataService)
>
>
>As I said above, this all works fine... the problem arose when I added
>a method to the MaxDataService component that used the following code:
>
> ' Get the URL to the vendor's service component
>[1] Dim mdsURL As String =
>Me.GetDataServiceURL(soldevent.VendorMemberID)
>
> ' Obtain connection to the vendor's service component...
>[2] Dim mds As MaxDataService = CType(Activator.GetObject( _
> GetType(MaxDataService), mdsURL), MaxDataService)
>
> ' Test the connection...
>[3] Dim test As String = mds.Greetings
>
>
>Tracing through this code, I know that we have a valid URL after line
>[1], and we have a non-null value for 'mds' after line [2] (mds has a
>value of type transparentProxy), but when we try to invoke the simple
>test member named Greetings in line [3], the "unknown remoting error"
>exception is thrown.
>
>
>Originally, I used the two lines of code shown below right above line
>[2]:
>
> Dim channel As HttpChannel = New HttpChannel(Nothing, New
>BinaryClientFormatterSinkProvider(), Nothing)
> ChannelServices.RegisterChannel(channel)
>
>...but I had to remove them because the RegisterChannel call threw an
>exception stating that the channel was already registered.
>
>
>Just out of curiosity, I tried the line of code shown below instead of
>line [2] to see what would happen:
>
> RemotingConfiguration.RegisterWellKnownClientType(GetType(MaxDataService),
>mdsURL)
>
>...but this line threw an exception with the following message:
>
>Attempt to redirect activation for type 'DataServices.MaxDataService,
>MaxDataService'. This is not allowed since either a well-known
>service type has already been registered with that type or that type
>has been registered has a activated service type.
>
>I'm assuming my problem is that I'm trying to register a given type as
>a remoted type when that type is already known locally (?), but I
>can't believe that I'm the only one who ever wanted to do such a thing
>- there has to be a way to connect two components of the same type
>through .NET remoting (I hope?).
>
>Can anyone help?



Relevant Pages

  • Re: Accessing secure and unsecure services from same app domain
    ... The server has 2 channels ... There's one secure server and client, ... the first channel I register is always used. ...
    (microsoft.public.dotnet.framework.remoting)
  • Registering two channels
    ... I need to register two channels but the system only seems to recognize one. ... I have a server which has two-way remoting with its clients. ... Now the server needs to act as a client to another server. ... attach a security sink on the the client side of a channel. ...
    (microsoft.public.dotnet.framework.remoting)
  • Secure and Unsecure channels in same app domain
    ... Each channel is bound to a object. ... register unsecure channel ... static void StartUnsecure() ... public class Server ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: HELP: pass object to client from a different appdomain
    ... My SAO/CAO design is to let server factory object register as IPC ... On this channel you publish a Sigleton. ... channel unless I manually fix or limit the number of clients connecting to ...
    (microsoft.public.dotnet.framework.remoting)
  • [Full-disclosure] Multiple vulnerabilities in ircu
    ... Ircu is the open source IRC server used on Undernet and other IRC networks. ... they allow clients to get more privileges on the IRC ... Gaining ops on channels that get empty on one side of a netsplit ... Making clients think someone is on a channel, ...
    (Full-Disclosure)