[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] Re: System.Net.WebException occurred when i use Xen C# SDK v1.1



TO: Shakil M Khan
CC: xen-api@xxxxxxxxxxxxxxxxxxx

Hi, Shakil M Khan and xen-api leaders.
Do you remember me :) , I hope to get your help about the following problem
in [Original Message] .

Recently,I try to make _proxy.KeepAlive = false; and use ssl(443 port)
to connect xen machine in C#. In unfortunately, I got a handle leak of my
app,
but if I just change _proxy.KeepAlive = true;(default way),this handle leak
is gone. 
The followint is my source sample,can you check it and tell me where is
wrong. :(

[Code Detail]
Public class GetXenTest
{
  Session mySession;

  Public SysmonXenSession GetSession(string host, string user, string
password)
  {
      _s = new Session(host, setting.XenRPCPort);
      _s.proxy.KeepAlive = false;   // <----------------------- (1)
      _s.login_with_password(user, password);
      Return _s;
  }

  Public RawData GetCPUUtilization()
  {
      mySession  = GetSession("192.168.1.2","root","password");

      //Use session to get host list 
      ...
      //get each cpu utilization of every host
      ...
  }
}


...
//Make SSL from Xen Session
public class SysmonXenSession : XenAPI.Session
{
  public SysmonXenSession(string host, int port)
        : base(host, port)
  {}

  static SysmonXenSession()
  {
        ServicePointManager.ServerCertificateValidationCallback = 
                                SysmonXenSession.ValidateServerCertificate;
      // The following 
      //new System.Net.Security.RemoteCertificateValidationCallback(    
      //           Session.ValidateServerCertificate);
  }

  private static bool ValidateServerCertificate(
        object sender,
        X509Certificate certificate,
        X509Chain chain,
        SslPolicyErrors sslPolicyErrors)
  {
        return true;
  }
}

Case One:
If I change (1) to "_s.proxy.KeepAlive = true;" I got the exception:
> System.Net.WebException
> The underlying connection was closed: A connection that was expected To be
kept
> alive was closed by the server.

Case One:
If I change (1) to "_s.proxy.KeepAlive = false;" I got a handle leak.


Could you tell why this happened, please?
Could you tell how to fix it, advice is also helpful. 

Thank you so much.

Yours 
Wanghl (wanghl@xxxxxxxxxxxxxxxxxxxx)

> -----Original Message-----
> From: wanghl [mailto:wanghl@xxxxxxxxxxxxxxxxxxxx]
> Sent: Monday, December 24, 2007 3:59 PM
> To: 'xen-api@xxxxxxxxxxxxxxxxxxx'
> Subject: System.Net.WebException occurred when i use Xen C# SDK v1.1
> 
> Hi
> When I use Xen C# SDK v1.1 to get Xen Host's Cpu Utilization every minute,
I
> have got an exception below aperiodically.  :(
> 
> System.Net.WebException
> The underlying connection was closed: A connection that was expected To be
kept
> alive was closed by the server.
> 
> Just as we know, v1.1 sdk doesn't implement xenapi's logout or dispose
method
> now,just login method can be used. Maybe this is why "_proxy.KeepAlive =
true;"
> is  there in the XenAPI.Session Class's constructor.
> But there has an issue about this exception in www.xml-rpc.net.
> http://www.xml-rpc.net/faq/xmlrpcnetfaq.html#2.27
> Detail is
> 2.27 How can I stop a WebException being thrown?
> The Underlying Connection Was Closed
> When an instance of WebException is thrown with this message "The
underlying
> connection was closed: A connection that was expected to be kept alive was
> closed by the server", try setting the KeepAlive property on the proxy to
false.
> 
> If I change xen session's proxy.keepalive to false, is there other problem
would
> occurre ?
> 
> Dose someone can tell me how to do ?
> 
> Thanks :)
> 
> Kino (wanghl@xxxxxxxxxxxxxxxxxxxx)


_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.