Re: SocketException at GetLifetimeService

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Chadi Zwein (zwein_at_hotmail.com_)
Date: 06/30/04


Date: Wed, 30 Jun 2004 17:39:17 +0300

I'll try to do that. The problem is that the error is only occuring in a
test site located far in Germany!
In the meantime here is some usefule code:

thx

   try
   {
    // initialize the state machine
    remoteObjects = this.CreateRemoteObject();
    if((remoteObjects.adminObject == null)||(remoteObjects.sponsorObject ==
null))
     return false;

    //Activate the renewal mechanism
    instanceSponsor = (InstanceSponsor)remoteObjects.sponsorObject;
    serverLease =
(ILease)RemotingServices.GetLifetimeService((MarshalByRefObject)remoteObject
s.adminObject);
    serverLease.Register((ISponsor)instanceSponsor);
   }
   catch(Exception e)
   {
    errorNumber = (long)ErrorCollection.CreateCredential_CreateRemoteObject;
    errorDescription = e.Message;
   }

private RemoteObjects CreateRemoteObject()
{
 try
 {
  //setting up the transfer channel and creating the object
  TcpClientChannel clientChannel = new TcpClientChannel("", new
BinaryClientFormatterSinkProvider());
  channel = clientChannel as IChannel;
  ChannelServices.RegisterChannel(channel);

  object[] attrs = {new UrlAttribute(this.serverURL)};
  ObjectHandle oh =
Activator.CreateInstance("SE.Admin.Server","SE.Admin.Server.AdminServer",att
rs);
  object sponsorObj =
Activator.GetObject(typeof(SE.Admin.Server.InstanceSponsor),
this.sponsorURL);
  object adminObj = oh.Unwrap();

  return new RemoteObjects(adminObj, sponsorObj);
 }
 catch(Exception e)
 {
  Debug.WriteLine(e.ToString());
  throw e;
 }
}

"Sunny" <sunnyask@icebergwireless.com> wrote in message
news:OVOEJReXEHA.2520@TK2MSFTNGP12.phx.gbl...
> Hi,
> can you post some code?
>
> And what happens, if you create a remote object and try to execute a
> method on it, without invoking GetLifetimeService?
>
>
> Sunny
>
>
> In article <enVnt#dXEHA.3668@TK2MSFTNGP09.phx.gbl>, zwein@hotmail.com_
> says...
> > This is a CAO scenario with lifetime management.
> > The remote objects are created successfully!! (no exceptions).
> >
> > Following that, and in the function calling
> > RemotingServices.GetLifetimeService on the remote object, a
> > System.Net.Sockets.SocketException occurs, complaining that the server
did
> > not respond in a timely fashion or the connection to the server was
reset...
> >
> > Server Stack Trace:
> > at System.Net.Sockets.Socket.Connect(EndPoint remote EP)
> > at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket()
> > at System.Runtime.Remoting.Channels.SocketCache.GetSocket(String
> > machineAndPort)
> > :
> > :
> > Exception Rethrown at [0]:
> > at System.Runtime.Remoting.Proxies.RealProxy...
> > :
> > at System.Runtime.MarshalByRefObject.GetLifetimeService()
> > at MyFunction()
> >
> >
> > This error is occurring on exactly 1 testing site among 40 to 50 ones,
but
> > it always appears there. Nothing interesting in the event logs, and the
IP
> > configuration of both (Windows 2000 SP4) client and server machines is
very
> > basic. No firewalls involved.
> >
> > Any idea?
> >
> >
> >