WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

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

To: <smkhan@xxxxxxxxxx>
Subject: [Xen-API] Re: System.Net.WebException occurred when i use Xen C# SDK v1.1
From: "wanghl" <wanghl@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 14 Jan 2008 18:03:52 +0800
Cc: xen-api@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 14 Jan 2008 02:01:02 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
Importance: High
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Reply-to: wanghl@xxxxxxxxxxxxxxxxxxxx
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AchWlMPfx0tTN+5ySqubRgUkdk8dIQ==
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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] Re: System.Net.WebException occurred when i use Xen C# SDK v1.1, wanghl <=