Remoting timeout

Posted on 2005-04-08
Last Modified: 2012-06-21
I'm marshalling this ByRef object, and i connect to it from a client.. all goes very well, but when the client disconnects for some minutes, reconnecting results in "cannot find requested service" when calling a method on the ByRef object.  I assume the lifetime of my server-object has expired.  Can i make this infinite? (Code below)

I think my problem would be better resolved using Client-Activated objects, but in that case i have no clue how to make that object communicate with the rest of my service, for instance, to return statistics about what the service is doing.  My problem is that i should be able to get a reference in that client-activated object to any other class in the service but because the object is virtually constructed at client's side, i cannot drop in an argument in the constructor from service-side.  Any help here?

Back to my current plan, here's the code:

Marshalling a MarshalByRef object from a main controller object in the service:

'Open a Tcp channel for communication
Dim aChannel As New TcpChannel(6000)

'Create publishing object and "Marshal" it (= make available to remote processes)
FDataPublisher = New DataPublisher(Me)
RemotingServices.Marshal(FDataPublisher, "DataPublisher.rem")

The MarshalByRef object looks like this (The FDataProvider is the "Me" in previous code-part, and is a main controller object):

Public Class DataPublisher
    Inherits MarshalByRefObject

    Protected FDataProvider As IDataProvider

    Public Sub New(ByVal ADataProvider As IDataProvider)
        FDataProvider = ADataProvider
    End Sub

    Public Function GetData() As Data
        Return FDataProvider.GetData()
    End Function

   ' blabla, some more functions that return or change data

End Class

And finally, my client connects like this in the "Load" eventhandler of the mainform:

Dim InfoPublisher As Object = Activator.GetObject(GetType(DataPublisher), "tcp://localhost:6000/DataPublisher.rem")
FDataPublisher = CType(InfoPublisher, DataPublisher)

The crash occurs when not having used the service for some time, and then launching the client again and requesting a remote-method again.  Like this:

Dim myData As Data = FDataPublisher.GetData()

thank you,

Question by:ICTSYSTEMS
    LVL 23

    Accepted Solution


        Public Overrides Function InitializeLifetimeService() As Object
            Return Nothing
        End Function

    In your MarshalByRefObject gives it an infinite lifetime.
    LVL 1

    Author Comment

    easy money :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now