Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

SERIOUS USPS PROBLEM


  • You cannot reply to this topic
12 replies to this topic

#1 daniellosada

  • Community Member
  • 16 posts
  • Real Name:Real Name
  • Gender:Male

Posted 28 November 2008, 18:18

Warning: fsockopen() [function.fsockopen]: unable to connect to production.shippingapis.com:80 in /home/u7/jostom/html/shop/osc/includes/classes/http_client.php on line 330

Ive looked through the forums, and i couldnt resolve my problem. I need a different solution than what has already been posted about this error.


Additional Details:
1. I have contacted usps them and they have already moved me to production, i have put in my usps id and password into the oscommerce admin for usps module.
2. The module WAS working, then bam! just stopped working after the usps change. not too sure tho if it was usps, since i had slightly modified a few files.


I hope I have given enough details, Any help would be greatly appreciated. I can probably give better details based on your responses.

Thanks alot !

Daniel Losada

#2 kymation

  • Community Sponsor
  • 5,285 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 28 November 2008, 20:23

Are you using the stock osCommerce USPS module? If so, try the latest version of the USPS Methods contribution.

Regards
Jim

#3 daniellosada

  • Community Member
  • 16 posts
  • Real Name:Real Name
  • Gender:Male

Posted 01 December 2008, 06:45

upgraded it and still the same error. anything to do with http_clients, weight, or maybe the address i put in?

#4 daniellosada

  • Community Member
  • 16 posts
  • Real Name:Real Name
  • Gender:Male

Posted 01 December 2008, 07:21

please help

#5 daniellosada

  • Community Member
  • 16 posts
  • Real Name:Real Name
  • Gender:Male

Posted 01 December 2008, 16:07

Does anyone know how the shipping code is suppose to work throughout oscommerce? which files can mess up the USPS shipping module?

I have replaced the shipping files to the original, and i still get an error from a file i didnt touch (the http_client). I know that other people had this same error, but that was a production/test issue. I have already been moved to shipping. USPS changed something tho, i think it was their urls. where is this in the oscommerce.

Anyone with ANY type of info on ANY of the oscommerce files that have to do with shipping, please fill me in. even if its just a list of all the files that have code that, if changed, can mess up the usps shipping calculation on the checkout_shipping.php page.

I would be greatful. I am really stuck. I really rely on this forum to help me fix this problem

#6 kymation

  • Community Sponsor
  • 5,285 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 01 December 2008, 18:30

If the USPS Methods version fails the same way, it's likely that your host is blocking HTTP requests. Ask them. If they are, you'd either have to rewrite the USPS module to use cURL (if your host has it installed) or switch hosts.

Regards
Jim

#7 daniellosada

  • Community Member
  • 16 posts
  • Real Name:Real Name
  • Gender:Male

Posted 01 December 2008, 18:58

View Postkymation, on Dec 1 2008, 07:30 PM, said:

If the USPS Methods version fails the same way, it's likely that your host is blocking HTTP requests. Ask them. If they are, you'd either have to rewrite the USPS module to use cURL (if your host has it installed) or switch hosts.

Regards
Jim


thank you very much. it is not working yet, but i contacted them, and i explained the problem again, til they understood. It turns out they did block it but they have a form that i can fill out to request an "unblock"

its probably it, but ill post back here if anyadditional problems come up. Thanks alot Jim. your very helpful

#8 daniellosada

  • Community Member
  • 16 posts
  • Real Name:Real Name
  • Gender:Male

Posted 08 December 2008, 21:40

I gave my hosting company the information for usps, but i still have the same error. I'm not sure which IP address to give them. It is not provided for by USPS. They only give the address. I did a whois on the URLs to ping their IPs but those IPs didnt work for my hosting company. What could my hosting company possibly want?

#9 minionsweb

  • Community Member
  • 168 posts
  • Real Name:Corey

Posted 08 December 2008, 22:01

Currently USPS is having shipping calc issues, it may not be associated with your install today if you have previously resolved the issue.

#10 daniellosada

  • Community Member
  • 16 posts
  • Real Name:Real Name
  • Gender:Male

Posted 08 December 2008, 22:03

how do i modify the shipping file to use cURL? and it WAS working before, so i dont think i have to switch hosting companies.

#11 daniellosada

  • Community Member
  • 16 posts
  • Real Name:Real Name
  • Gender:Male

Posted 08 December 2008, 22:05

View Postminionsweb, on Dec 8 2008, 10:01 PM, said:

Currently USPS is having shipping calc issues, it may not be associated with your install today if you have previously resolved the issue.


so shall i wait for USPS then? and who can i contact about this? Apparently they dont know they are having issues... :P

#12 USPSRateCalc

  • Community Member
  • 2 posts
  • Real Name:Adrian S. Griffith

Posted 10 December 2008, 15:53

View Postminionsweb, on Dec 8 2008, 05:01 PM, said:

Currently USPS is having shipping calc issues, it may not be associated with your install today if you have previously resolved the issue.

Hey folks,

The shipping api is down, however the rate calculator is available. We provide the rate calculation engine to the folks that provide the shipping api. The shipping api offers numerous services and we are just one of them.

If you require domestic rates calculations, as received by ShippingAPI.dll, you can access our rate engine directly.

Accessing the rate calculator api is very similiar to how you access this functionality from the shipping api.

Getting started:

A simple demo site that will allow you to learn/test a subset the API:
http://postcalc.usps.gov/domSDK/sdkdemo.htm

XML over HTTP Application access:
http://postcalc.usps.gov/SdkXml.aspx

Documentation is available but I do not have a publically available site to post this on. If a site is available, just let me know and I will post the SDK documentation there.

Let me know if I can help.
Adrian Griffith
ManTech Information Systems & Technology
Project Manager, USPS Postal Explorer and Rate Calculators

adrian.griffith@mantech.com

Edited by USPSRateCalc, 10 December 2008, 16:08.


#13 USPSRateCalc

  • Community Member
  • 2 posts
  • Real Name:Adrian S. Griffith

Posted 10 December 2008, 16:19

The link below is for programmatic access. You must format an XML request (like the SDK Demo link above) and perform a HTTP GET or POST to get a response.

XML over HTTP Application access:
http://postcalc.usps.gov/SdkXml.aspx

C# Example:

/// <summary>
/// Example of the GetRates Request.
/// </summary>
/// <param name="testOut">StreamWriter for output file</param>
private void TestGetRates(StreamWriter TestOut)
{
// C# HTTP Web Request and Response objects
HttpWebRequest wtReq;
HttpWebResponse wtResp = (HttpWebResponse)null;
HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);

// URL for this request
string reqUrl = "";

// an HTTP POST or GET are acceptable
string httpMethod = "POST";

// Some properties to handle formatting the request and output
StringBuilder xmlOutput = new StringBuilder();
StringBuilder example = new StringBuilder();
StringBuilder mClasses = new StringBuilder();
StringBuilder mClassesDesc = new StringBuilder();
StringBuilder xmlTestElement = new StringBuilder();
string poOutput = "";

// Parameters for the GetRates Request
eMailType mailType = eMailType.eLetter;
string origZip = "20151";
string destZip = "20011";
string characteristics = "";
double pounds = 0;
double ounces = 1;
string mailingDate = "-1";
string mailingTime = "-1";

// Future element that will allow the user to request a specific mail class
mClasses.AppendFormat("<MailClass />");
mClassesDesc.AppendFormat("Request all mail services available");

string testType = "GetRates";
++TestId;

// Formatted GetRates Request for output to disk as well as the HTTP Request content
example.AppendFormat("<GetRates TestId='{9}' TestUnitId='{10}'>\r\n" +
"<MailTypeID>{0}</MailTypeID>\r\n" +
"<CharacteristicID>{1}</CharacteristicID>\r\n" +
"<OZIP>{2}</OZIP>\r\n" +
"<DZIP>{3}</DZIP>\r\n" +
"<Pounds>{4}</Pounds>\r\n" +
"<Ounces>{5}</Ounces>\r\n" +
"<MailingDate>{6}</MailingDate>\r\n" +
"<MailingTime>{7}</MailingTime>\r\n" +
"<MailClasses>\r\n" +
"{8}\r\n" +
"</MailClasses>\r\n" +
"</GetRates>",
(int)mailType, characteristics, origZip, destZip, pounds, ounces, mailingDate, mailingTime, mClasses.ToString(),
TestId, TestUnitId);

// Create the HTTP Request content
string reqContent = example.ToString();
reqContent = reqContent.Replace("\r\n", "");

if (httpMethod == "POST")
{
reqUrl = "http://postcalc.usps.gov/SdkXml.aspx";
wtReq = (HttpWebRequest)WebRequest.Create(reqUrl);

// Set some common Request variables
wtReq.KeepAlive = true;
wtReq.CachePolicy = noCachePolicy;
wtReq.Timeout = 10000;
wtReq.Method = httpMethod;

// Build the content for the POST
byte[] byteRequest = Encoding.UTF8.GetBytes(reqContent);
wtReq.ContentType = "application/x-www-form-urlencoded";
wtReq.ContentLength = byteRequest.Length;
Stream dataStream = wtReq.GetRequestStream();
dataStream.Write(byteRequest, 0, byteRequest.Length);
dataStream.Close();
}
else
{
// Append the content for the GET
reqUrl = String.Format("http://postcalc.usps.gov/SdkXml.aspx?Xml={0}", reqContent);
wtReq = (HttpWebRequest)WebRequest.Create(reqUrl);
}

// Set some common Request variables
wtReq.KeepAlive = true;
wtReq.CachePolicy = noCachePolicy;
wtReq.Timeout = 10000;
wtReq.Method = httpMethod;

// Use a DataSet to capture the URL
DataSet ds = new DataSet();

// Might as well collect some performance information
Stopwatch sw = new Stopwatch();
sw.Start();

// Make the Request
try
{
wtResp = (HttpWebResponse)wtReq.GetResponse();
Stream recvStream = wtResp.GetResponseStream();
ds.ReadXml(recvStream);
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (wtResp != (WebResponse)null)
wtResp.Close();
}

sw.Stop();
long elapsedTime = sw.ElapsedMilliseconds;

xmlTestElement.AppendFormat("MailPieceType='{0}' TestType='{1}' " +
"Pounds='{2}' Ounces='{3}' OrigZip='{4}' DestZip='{5}' " +
"MailClasses='{6}' MailTypeId='{7}' MailingDate='{8}' MailingTime='{9}' " +
"TestId='{10}' TestUnitId='{11}' ElapsedMilliseconds='{12}'",
mailType, testType, pounds, ounces, origZip, destZip,
mClassesDesc.ToString(), (int)mailType, mailingDate, mailingTime, TestId, TestUnitId, elapsedTime);

TestOut.WriteLine("<TestXMLSdk " + xmlTestElement.ToString() + ">");
TestOut.WriteLine(example.ToString());

poOutput = ds.GetXml();

poOutput = poOutput.Replace("</MailClass>",
String.Format("<TestId>{0}</TestId>\r\n<TestUnitId>{1}</TestUnitId>\r\n</MailClass>", TestId, TestUnitId));

xmlOutput.Append(poOutput);
TestOut.WriteLine(xmlOutput.ToString());
TestOut.WriteLine("</TestXMLSdk>");

return;
}