carviaso / google-checkout-dotnet-sample-code

Automatically exported from code.google.com/p/google-checkout-dotnet-sample-code
0 stars 0 forks source link

"The underlying connection was closed" error #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Sandbox intermittently returns this error when you post carts from .NET code:

The underlying connection was closed: A connection that was expected to be
kept alive was closed by the server.

If the merchant-calculations part of the cart XML is removed this never
happens. If it's left in, the error above happens occasionally. I have
verified that the XML is valid. It is unclear if this is a problem with the
.NET code or with the Checkout Sandbox.

Original issue reported on code.google.com by martin.o...@gmail.com on 25 Sep 2006 at 11:36

GoogleCodeExporter commented 9 years ago
I can't reproduce it any more, but others can:
http://groups.google.com/group/google-checkout-api-dotnet/browse_thread/thread/a
6671844de4c91d5/59a3d8a8d16f71ad#59a3d8a8d16f71ad

Adding myRequest.KeepAlive = false; in the Send() method of GCheckoutRequest 
doesn't
seem to hurt, and some say it helps. Will check in that change.

Original comment by martin.o...@gmail.com on 24 Dec 2006 at 7:12

GoogleCodeExporter commented 9 years ago
Alex reports this may help as well:
myRequest.ProtocolVersion = HttpVersion.Version10;

Original comment by martin.o...@gmail.com on 3 Jan 2007 at 5:42

GoogleCodeExporter commented 9 years ago
I tried both and always get the same error, I am using this code to post, 
mostly 
copied from the API, with some changes, the last line fails with:

The underlying connection was closed: Unable to connect to the remote server. 

I am connecting to the url at:
string.Format("https://sandbox.google.com/checkout/cws/v2/Merchant/{0}/request",

Merchant_ID)

ANY ideas  or pointers on how to find out what is going wrong, are greatly 
apretiated

thanks!

private string Send(string xml, string url) {
  System.Text.ASCIIEncoding  encoding=new System.Text.ASCIIEncoding();
  byte[] Data = encoding.GetBytes(xml);
  HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
  myRequest.Method = "POST";
  myRequest.ContentLength = Data.Length;
  string authorization = "Basic " + GetAuthorization();
  myRequest.Headers.Add("Authorization",  authorization);
  myRequest.ContentType = "application/xml";
  myRequest.Accept = "application/xml";
  myRequest.KeepAlive = false;
  myRequest.ProtocolVersion = HttpVersion.Version10;
  Stream newStream = myRequest.GetRequestStream();

Original comment by kalvar...@CUBATROPICO.COM on 14 Jan 2007 at 11:34

GoogleCodeExporter commented 9 years ago
Found a good blog post about this error:
http://www.simple-talk.com/community/blogs/dana/archive/2006/07/28/1484.aspx

Original comment by martin.o...@gmail.com on 11 May 2007 at 6:41

GoogleCodeExporter commented 9 years ago
The error has not been reported in over two years. Closing the issue.

Original comment by joseph.f...@gmail.com on 16 Oct 2010 at 4:26