Remoting object - "Requested Service Not Found"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Lutz

    Remoting object - "Requested Service Not Found"

    Hi All,

    I have a Windows Service that runs well. The service hosts a remote object.
    The purpose of the object is so that I can "peak" into the service to see
    what it's doing. I wrote a small Windows Application that connects to the
    remote object and prints out status information.
    Everything works fine when I first start the service. However, after some
    period, when I attempt to connect to the remote object, I get "Requested
    Service not Found" when I try to bind to it.

    I can confirm that the Service is still running, because it is doing what it
    is supposed to be doing (processing logfiles) but the Remote Object isn't
    working. The Remote Object is instantiated in the main thread for the
    service, so it's not that the remote object is getting destroyed.

    Some more troubleshooting shows that it isn't on the second connection
    attempt that I cannot connect. I thought it might be the local object
    destroying the remote object when the "client" app closes. This doesn't seem
    to be the case.

    The instance of the remote object is populated by the service with
    information as it is running. So I'm fairly certain the the actual instance
    of the object still exists, because if it was destroyed, then the service
    would probably crash, which it doesn't.

    Anyone have any ideas on what I'm doing wrong or not doing?

    Here is the server side code that creates the object: (Object name is
    "AllStatus" )

    HttpChannel channel = new
    HttpChannel(Con vert.ToInt32(Co nfigurationSett ings.AppSetting s["StatusPort "])
    );
    ChannelServices .RegisterChanne l(channel);
    ObjRef refl = RemotingService s.Marshal(AllSt atus,"objectlur i");

    Here is the client code that attempts to connect to it:

    string RemoteConnectio n = "http://" + this.textBox1.T ext + ":" +
    this.textBox3.T ext + "/objectluri";

    RemotingConfigu ration.Register WellKnownClient Type(typeof(Ses sionLogger.Serv i
    ceStatus),Remot eConnection );
    object1 = new SessionLogger.S erviceStatus();

    To get the obvious questions out of the way, yes, I'm sure that the host and
    port numbers are the same.

    Thanks in Advance..

    Steve









  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Remoting object - "Reques ted Service Not Found"

    Steve,

    Is there a reason why you are not registering the type on the service
    side? My guess is that you are marshaling a reference, and that the lease
    is dying out. You should be configuring the type on the server to be
    marshaled (using the static RegisterWellKno wnServiceType method on the
    RemotingConfigu ration class).

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Steve Lutz" <slutzNOSPAM@co mcast.net> wrote in message
    news:Ofaj7SdMEH A.4036@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hi All,
    >
    > I have a Windows Service that runs well. The service hosts a remote[/color]
    object.[color=blue]
    > The purpose of the object is so that I can "peak" into the service to see
    > what it's doing. I wrote a small Windows Application that connects to the
    > remote object and prints out status information.
    > Everything works fine when I first start the service. However, after some
    > period, when I attempt to connect to the remote object, I get "Requested
    > Service not Found" when I try to bind to it.
    >
    > I can confirm that the Service is still running, because it is doing what[/color]
    it[color=blue]
    > is supposed to be doing (processing logfiles) but the Remote Object isn't
    > working. The Remote Object is instantiated in the main thread for the
    > service, so it's not that the remote object is getting destroyed.
    >
    > Some more troubleshooting shows that it isn't on the second connection
    > attempt that I cannot connect. I thought it might be the local object
    > destroying the remote object when the "client" app closes. This doesn't[/color]
    seem[color=blue]
    > to be the case.
    >
    > The instance of the remote object is populated by the service with
    > information as it is running. So I'm fairly certain the the actual[/color]
    instance[color=blue]
    > of the object still exists, because if it was destroyed, then the service
    > would probably crash, which it doesn't.
    >
    > Anyone have any ideas on what I'm doing wrong or not doing?
    >
    > Here is the server side code that creates the object: (Object name is
    > "AllStatus" )
    >
    > HttpChannel channel = new
    >[/color]
    HttpChannel(Con vert.ToInt32(Co nfigurationSett ings.AppSetting s["StatusPort "])[color=blue]
    > );
    > ChannelServices .RegisterChanne l(channel);
    > ObjRef refl = RemotingService s.Marshal(AllSt atus,"objectlur i");
    >
    > Here is the client code that attempts to connect to it:
    >
    > string RemoteConnectio n = "http://" + this.textBox1.T ext + ":" +
    > this.textBox3.T ext + "/objectluri";
    >
    >[/color]
    RemotingConfigu ration.Register WellKnownClient Type(typeof(Ses sionLogger.Serv i[color=blue]
    > ceStatus),Remot eConnection );
    > object1 = new SessionLogger.S erviceStatus();
    >
    > To get the obvious questions out of the way, yes, I'm sure that the host[/color]
    and[color=blue]
    > port numbers are the same.
    >
    > Thanks in Advance..
    >
    > Steve
    >
    >
    >
    >
    >
    >
    >
    >
    >[/color]


    Comment

    • richlm

      #3
      RE: Remoting object - &quot;Reques ted Service Not Found&quot;

      Are you instantiating the remoting object in Main() ??? That's probably not the right place to do it - try initialising your remoting layer in the OnStart() event

      There's an article here that describes something similar to what you are doing

      Comment

      • Steve Lutz

        #4
        Re: Remoting object - &quot;Reques ted Service Not Found&quot;

        Hi Nicholas,

        I was able to figure out the problem, it WAS because the lease was dying. My
        problem is that I needed the remote client to connect to the same instance
        of the object, not a new one. I read that if I did a singleton, it would
        only create one object of the class, but it seems that it was creating one
        instance of the class for remote clients, and one for non-remote. This
        wouldn't work, and this is the only way I could find to have a remote client
        connect to the same instance of a local instantiated object.

        I fixed it by overriding the default
        MarshalByRefObj ect.InitializeL ifetimeService to return null, which tells
        Remoting that the lease should never expire.

        Unless you know of a way to have a remote object connect to an exisiting
        instance of a class that the server created, I think I'm going to stick with
        this method.

        Thanks

        Steve



        "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
        message news:%23t6qYgdM EHA.4036@TK2MSF TNGP12.phx.gbl. ..[color=blue]
        > Steve,
        >
        > Is there a reason why you are not registering the type on the service
        > side? My guess is that you are marshaling a reference, and that the lease
        > is dying out. You should be configuring the type on the server to be
        > marshaled (using the static RegisterWellKno wnServiceType method on the
        > RemotingConfigu ration class).
        >
        > Hope this helps.
        >
        >
        > --
        > - Nicholas Paldino [.NET/C# MVP]
        > - mvp@spam.guard. caspershouse.co m
        >
        > "Steve Lutz" <slutzNOSPAM@co mcast.net> wrote in message
        > news:Ofaj7SdMEH A.4036@TK2MSFTN GP12.phx.gbl...[color=green]
        > > Hi All,
        > >
        > > I have a Windows Service that runs well. The service hosts a remote[/color]
        > object.[color=green]
        > > The purpose of the object is so that I can "peak" into the service to[/color][/color]
        see[color=blue][color=green]
        > > what it's doing. I wrote a small Windows Application that connects to[/color][/color]
        the[color=blue][color=green]
        > > remote object and prints out status information.
        > > Everything works fine when I first start the service. However, after[/color][/color]
        some[color=blue][color=green]
        > > period, when I attempt to connect to the remote object, I get[/color][/color]
        "Requested[color=blue][color=green]
        > > Service not Found" when I try to bind to it.
        > >
        > > I can confirm that the Service is still running, because it is doing[/color][/color]
        what[color=blue]
        > it[color=green]
        > > is supposed to be doing (processing logfiles) but the Remote Object[/color][/color]
        isn't[color=blue][color=green]
        > > working. The Remote Object is instantiated in the main thread for the
        > > service, so it's not that the remote object is getting destroyed.
        > >
        > > Some more troubleshooting shows that it isn't on the second connection
        > > attempt that I cannot connect. I thought it might be the local object
        > > destroying the remote object when the "client" app closes. This doesn't[/color]
        > seem[color=green]
        > > to be the case.
        > >
        > > The instance of the remote object is populated by the service with
        > > information as it is running. So I'm fairly certain the the actual[/color]
        > instance[color=green]
        > > of the object still exists, because if it was destroyed, then the[/color][/color]
        service[color=blue][color=green]
        > > would probably crash, which it doesn't.
        > >
        > > Anyone have any ideas on what I'm doing wrong or not doing?
        > >
        > > Here is the server side code that creates the object: (Object name is
        > > "AllStatus" )
        > >
        > > HttpChannel channel = new
        > >[/color]
        >[/color]
        HttpChannel(Con vert.ToInt32(Co nfigurationSett ings.AppSetting s["StatusPort "])[color=blue][color=green]
        > > );
        > > ChannelServices .RegisterChanne l(channel);
        > > ObjRef refl = RemotingService s.Marshal(AllSt atus,"objectlur i");
        > >
        > > Here is the client code that attempts to connect to it:
        > >
        > > string RemoteConnectio n = "http://" + this.textBox1.T ext + ":" +
        > > this.textBox3.T ext + "/objectluri";
        > >
        > >[/color]
        >[/color]
        RemotingConfigu ration.Register WellKnownClient Type(typeof(Ses sionLogger.Serv i[color=blue][color=green]
        > > ceStatus),Remot eConnection );
        > > object1 = new SessionLogger.S erviceStatus();
        > >
        > > To get the obvious questions out of the way, yes, I'm sure that the host[/color]
        > and[color=green]
        > > port numbers are the same.
        > >
        > > Thanks in Advance..
        > >
        > > Steve
        > >
        > >
        > >
        > >
        > >
        > >
        > >
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...