• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

Remoting timeout

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)
ChannelServices.RegisterChannel(aChannel)

'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,

Thomas
0
IT Meetjesland
Asked:
IT Meetjesland
1 Solution
 
Jens FiedererTest Developer/ValidatorCommented:
Defining

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

In your MarshalByRefObject gives it an infinite lifetime.
0
 
IT MeetjeslandAuthor Commented:
easy money :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now