USPS 500 error

  • Posts: 100
  • Thank you received: 2
11 years 2 weeks ago #131592

-- url of the page with the problem -- : gravestonstudies.org
-- HikaShop version -- : Business 2.2.2
-- Joomla version -- : 2.5.14
-- PHP version -- : 5.4.20
-- Browser(s) name and version -- : any
-- Error-message(debug-mod must be tuned on) -- : error: Call to a member function xpath() on a non-object in /home3/gravest3/public_html/plugins/hikashopshipping/usps/usps.php on line 371
[09-Nov-2013 05:48:27 America/Denver] PHP Fatal

Hi,

I have a weird problem that has suddenly occurred since going live with my new site.When trying to access the USPS shipping plugin I get a 500 error. I have a weight restriction of 3.25 oz under restrictions so anything under that weight will trigger FREE shipping (manual shipping).

As I said, this was working until today so I'm not sure what the problem could be or what might have changed. I went live yesterday afternoon and it was working. Two orders came in overnight (the customers chose Priority Mail) -- so it must have been working then.

I'm stumped -- any help would be greatly appreciated.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 2
11 years 2 weeks ago #131598

UPDATE: I contacted the host to see if they could see any discrepancies in the PHP versions or anything that might be throwing these errors on their end --- no discrepancies. The usps.php file was changed three days ago probably when I upgraded from Hikashop Essential to Business. The only other files that have changed in the last 24 hours were my htaccess file (when I went live) and the error logs.

I continue to get the 500 errors when trying to place an order that requires shipping:

[09-Nov-2013 07:34:14 America/Denver] PHP Fatal error: Call to a member function xpath() on a non-object in /home3/gravest3/public_html/plugins/hikashopshipping/usps/usps.php on line 371

Thanks for your help in advance.

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 2
11 years 2 weeks ago #131599

I also just tried:

  • disabling and re-enabling the USPS plugin.
  • removing the weight restriction

I also discovered one of my other web sites running Hikashop Business and using the USPS plugin is showing the exact error when trying to purchase a product. Could something have changed on the USPS servers?

Is anyone else having this problem? I am based in Massachusetts, USA.

Last edit: 11 years 2 weeks ago by joanne721.

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 2 weeks ago #131642

Hi,

XPath is a feature of "SimpleXMLElement" introduced in PHP 5.2.0
us1.php.net/manual/fr/simplexmlelement.xpath.php

It should be an activated module in your PHP (5.4.20).
Please check you have the module activated.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 2
11 years 2 weeks ago #131644

Thanks for the help.

I have two web sites with this problem -- each running a slightly different version of PHP -- each on different hosts -- one that has been up and running perfectly for months and only just today started throwing errors. The other went live yesterday and worked fine during development and only today started throwing errors.

Why would both sites coincidentally and suddenly have this xpath module turn itself off? I changed nothing on either account.

Where do I check to make sure it's on?

Update: I just checked both sites under system information > php information and xpath is enabled.

Attachments:
Last edit: 11 years 2 weeks ago by joanne721.

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 2
11 years 2 weeks ago #131671

My USPS plugin problem breaks the sites with the plugin enabled whenever a visitor tries to enter their address and click NEXT -- so I have turned off USPS shipping on one of the sites (I have a UPS alternative set up at amykandco.com) but the other site (gravestonestudies.org) ONLY uses USPS so that site is still broken.

ANY information would be helpful at this point. Can I provide access to the admin panel?

Thank you in advance.

Please Log in or Create an account to join the conversation.

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
11 years 2 weeks ago #131710

After the line:
$response_xml = $this->doUSPS($request, true);
you should add the line:
if(!$response_xml) return false;
in the file plugins/hikashopshipping/usps/usps.php so that when the plugin cannot connect to USPS, it doesn't through a fatal error like you have.
However, the real issue here is that the plugin cannot connect to the USPS server and that's because your hosting company is apparently blocking outgoing connections from your server. So you will have to contact your hosting company to really solve the problem.

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 2
11 years 2 weeks ago #131711

Thanks, I'll add the code.

I have two sites with the same error on two different hosts -- would both hosts decide to block outgoing connections on the same day? It sounds a little unlikely. Especially since both sites were working well until yesterday morning.

Also, the UPS plugin works -- does that count as an outgoing connection?

In the meantime, I'll check with the two hosts and have turned off USPS plugin -- using manual on one site and UPS on the other.

Please Log in or Create an account to join the conversation.

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
11 years 2 weeks ago #131716

Then maybe it's a different issue. But that still means that the outgoing connection to USPS failed.

Change the line:
$app->enqueueMessage( 'Cannot connect to USPS web service. You hosting company might be blocking outbound connections');
to:
$app->enqueueMessage( 'Cannot connect to USPS web service. You hosting company might be blocking outbound connections.<br/>'.$errno.' '.$errstr);

And the error displayed will tell you exactly why the connection was refused.

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 2
11 years 2 weeks ago #131721

I'll try that. I would love more information in the error message.

Both site owners prefer USPS as a shipping method and I don't have a good reason for them why it stopped working. It's not like I can call the United States Postal Service and ask them if they changed something or whether their servers are down!

Thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 16
  • Thank you received: 3
11 years 2 weeks ago #131722

I'm having the same problem. Changing the line about not being able to connect did not give me any more information than I already had. Errors I get are.

Notice: Trying to get property of non-object in /home/christia/public_html/cgn/plugins/hikashopshipping/usps/usps.php on line 308
Notice: Trying to get property of non-object in /home/christia/public_html/cgn/plugins/hikashopshipping/usps/usps.php on line 314
Notice: Trying to get property of non-object in /home/christia/public_html/cgn/plugins/hikashopshipping/usps/usps.php on line 314
Fatal error: Call to a member function xpath() on a non-object in /home/christia/public_html/cgn/plugins/hikashopshipping/usps/usps.php on line 366


I can connect to UPS successfully, so if this is truly my host blocking connections, I'll need to know what port needs to be opened for USPS.

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 2
11 years 2 weeks ago #131723

I changed the line in my usps.php too but my error log only gives me:

[10-Nov-2013 14:22:32 America/Denver] PHP Fatal error: Call to a member function xpath() on a non-object in /home3/gravest3/public_html/plugins/hikashopshipping/usps/usps.php on line 741

Is there somewhere else to view errors?

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 1 week ago #131815

Hi,

As Nicolas said, if you have this error, it means that you can't connect the to "production.shippingapis.com" web service.
In the usps plugin, please replace:

		if ($isInternational)
			$response_xml = $this->doUSPS($request, false);
		else
			$response_xml = $this->doUSPS($request, true);
By:
		if ($isInternational)
			$response_xml = $this->doUSPS($request, false);
		else
			$response_xml = $this->doUSPS($request, true);

		if($response_xml === false) {
			 return;
		}
And it will avoid the PHP warning/error messages. At this moment you will see the message telling that the server can't connect to USPS.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 16
  • Thank you received: 3
11 years 1 week ago #131828

Thanks, when I go to my hosting company, what port shall I tell them to open? I have the URL obviously, but there must be a port that must be opened. I can't imagine they would block outgoing on port 80 or 443. So if you can tell me what port or range of ports this API uses, that would be most helpful.

Thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
11 years 1 week ago #131829

It's port 80.

Please Log in or Create an account to join the conversation.

  • Posts: 26
  • Thank you received: 0
11 years 1 week ago #131857

same problem. thanks nicolas for directing me to this thread.

problem started in the last 1-2 days only, with the following in error log:


[Mon Nov 11 13:04:55 2013] [error] [client 72.28.152.198] PHP Notice: Trying to get property of non-object in /var/www/vhosts/default/htdocs/plugins/hikashopshipping/usps/usps.php on line 224, referer: emotorwerks.com/products/online-store
[Mon Nov 11 13:04:55 2013] [error] [client 72.28.152.198] PHP Notice: Trying to get property of non-object in /var/www/vhosts/default/htdocs/plugins/hikashopshipping/usps/usps.php on line 231, referer: emotorwerks.com/products/online-store
[Mon Nov 11 13:04:55 2013] [error] [client 72.28.152.198] PHP Notice: Trying to get property of non-object in /var/www/vhosts/default/htdocs/plugins/hikashopshipping/usps/usps.php on line 231, referer: emotorwerks.com/products/online-store
[Mon Nov 11 13:04:55 2013] [error] [client 72.28.152.198] PHP Fatal error: Call to a member function xpath() on a non-object in /var/www/vhosts/default/htdocs/plugins/hikashopshipping/usps/usps.php on line 239, referer: emotorwerks.com/products/online-store

I doubt that the problem is caused by anything on hikashop's users' side (e.g., hosting company blocking outgoing connections etc) given that we all independently have the same problem appearing out of the blue around the same time.

For now, we have disabled USPS plugin which means we cannot accept international shipments.

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 1 week ago #131863

Hi,

The best is to know what is the result of UPS.
Can you please change temporally this:

			$responseBody = $this->getResponseXML($buffer);
			$responseDoc = simplexml_load_string($responseBody);
Into this:
			$responseBody = $this->getResponseXML($buffer);
die( $responseBody );
			$responseDoc = simplexml_load_string($responseBody);
It will allow you to send us the reply of UPS. So we will be able to understand the result and why it is not read correctly by the plugin.
You can also see the buffer before the processing:
die( $buffer );
			$responseBody = $this->getResponseXML($buffer);
			$responseDoc = simplexml_load_string($responseBody);
Maybe the problem is in the "getResponseXML" function..

It will help us to investigate.

Thanks,

PS: Don't forget to remove the modifications just after, it is just for debuging purpose. In order to see (with a fast patch) what is the processing content.


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 2
11 years 1 week ago #131865

I contacted the host of one of my affected sites. They said if port 80 were blocked the web site wouldn't come up at all. Port 80 is for http access and is bi-directional -- I'll call the other host shortly and see what they suggest.

I called USPS technical support too, but they're closed today (Remembrance Day here in US). Here's the info I have in case anyone is interested. I'll try calling them tomorrow -- maybe they changed something on their production server and can point us in the right direction?

USPS Internet Customer Care Center (ICCC)
The ICCC is staffed from 7:00AM to 11:00PM Eastern Time.
Email: This email address is being protected from spambots. You need JavaScript enabled to view it.
Telephone: 1-800-344-7779 (7:00AM to 11:00PM ET)

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 1
11 years 1 week ago #131870

Hi,

I applied the following modifications I found in the other thread in the the USPS plugin

_______________________

if ($isInternational)
$response_xml = $this->doUSPS($request, false);
else
$response_xml = $this->doUSPS($request, true);

if($response_xml === false) {
return;
}

_______________________

Now when I am trying to add a product to the cart I obtain the following message:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

_____________________________

Now there is not indication of the usps plugin problem...

What do you think?
I have to solve this issue as soon as I can.

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 1
11 years 1 week ago #131872

I have the same problem as joanne721...

and USPS is closed today...

Do you have a temporary solution to solve the postal fees issue for today?

Please Log in or Create an account to join the conversation.

Time to create page: 0.133 seconds
Powered by Kunena Forum