VB.Net Remoting Timeout Issue

Posted on 2011-05-09
Last Modified: 2012-05-11
Does anybody know if there is a way to modify the timeout associated with remoting?  

We have a 3.5 console application which uses remoting for executing application code. Below is the method and app.config key used to remote.  

It seems that the process on the client machine times out after around 20 minutes.  We have a job that runs a large SQL job which can take 30-45 minutes and right now we are forced to do it in 2 different calls which is very messy.  Anyway to prevent the client to timeout when using remoting?

Thanks ahead of time.
Private Sub ConfigureRemoting()                   RemotingConfiguration.RegisterWellKnownClientType(GetType(BusinessRules.CreditSystem), System.Configuration.ConfigurationManager.AppSettings("Application.Credit.Server"))
        End Sub

<add key="Application.Credit.Server" value="http://localhost/applicationserver/creditsystem.rem" />

Open in new window

Question by:kruegerste
    LVL 85

    Accepted Solution

    In your class that Inherits MarshalByRefObject, override the InitializeLifetimeService() function and return Nothing:
    Public Class MyRemotingObject
        Inherits MarshalByRefObject
        Public Overrides Function InitializeLifetimeService() As Object
            Return Nothing ' <-- Keep our instance from being garbage collected
        End Function
    End Class

    Open in new window

    This will give your object infinite life and it will not be garbage collected...
    LVL 85

    Assisted Solution

    by:Mike Tomlinson
    See Managing the Lifetime of Remote .NET Objects with Leasing and Sponsorship:

    In the Leasing Specifics section:

        "Fortunately, infinite lease time is supported. When you design a singleton object, override InitializeLifetimeService and return a null object as the new lease, indicating that this lease never expires"
    LVL 4

    Author Comment

    THanks for the suggestion.  Is there anyway though to set the actual timeout or just extend it?  

    The main issue is that the public class that inherits MarshalByRefObject contains methods for all sorts of different applications. It is very large to say the least. Is this override going to create issues with garbage collecting on these other methods?  What is the impact of making this change?  
    LVL 4

    Author Comment

    Oh, and I didn't see your 2nd post until after my follow-up, but I wanted to add that i don't think we are using a singleton object per-say. I'm concerned this technique might create other issues with our application.
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    The MSDN article I linked explains the leasing model if you want to specify a time limit and then extend that lease each time it expires.
    LVL 4

    Author Closing Comment


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    745 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

    16 Experts available now in Live!

    Get 1:1 Help Now