Zen Cart Logo
Forums / Currencies & Sales Taxes, VAT, GST, etc. / Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

Views: 18,194

Results 1 to 15 of 15
11 Jul 2016, 2:50 AM
#1
oavs avatar

oavs

Totally Zenned

Join Date:
Jan 2006
Location:
Downunder - QLD - Gold Coast
Posts:
921
Plugin Contributions:
0

Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

Hi

I have just installed new 1.5.5a and for every currency I have I am getting warnings for each currency. Can anyone suggest a solution please

=======================
Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US Dollar (USD) - trying the secondary exchange rate server.
Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for Euro (EUR) - trying the secondary exchange rate server.
Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for GB Pound (GBP) - trying the secondary exchange rate server.
Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for Australian Dollar (AUD) - trying the secondary exchange rate server.

also

TEXT_VERSION_CHECK_BUTTON showing instead of the button.
(You are presently using: v1.5.5a)

after clicking the link it returns to normal text as it should saying
"Your version of Zen Cart® appears to be current.
(You are presently using: v1.5.5a)"

11 Jul 2016, 4:55 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

  1. Currency updates since v155 are now handled by the server which you've selected in Admin->Configuration->My Store-> primary/secondary Currency servers.
    So, if it's not finding CURRENCY_SERVER_PRIMARY that means your database wasn't upgraded or installed properly.

  2. And your english.php language file appears to be the old one, since the v155a file is correct:
    /admin/includes/languages/english.php:
    379: define('TEXT_VERSION_CHECK_BUTTON', 'Check for New Version');

3 Aug 2017, 4:24 AM
#3
jacksback2 avatar

jacksback2

New Zenner

Join Date:
Jun 2010
Posts:
10
Plugin Contributions:
0

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

Having this exact issue after recent upgrade to V1.5.5e. How do I check database and how to resolve?

3 Aug 2017, 2:08 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

Jacksback2:

Having this exact issue after recent upgrade to V1.5.5e. How do I check database and how to resolve?
Since the database-upgrade step that's done via zc_install is what handles it, the first guess is that you didn't do that step?

4 Aug 2017, 6:34 AM
#5
jacksback2 avatar

jacksback2

New Zenner

Join Date:
Jun 2010
Posts:
10
Plugin Contributions:
0

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

The upgrade was done by qualified third party, so assume it was done correctly.

Did a test by doing a quick install of Zencart (via Softalucous) on two other hosting accounts with the same hosting company.
Ran "update currencies" and the same error:
Warning: The primary exchange rate server (ecb) failed for US Dollar (USD) - trying the secondary exchange rate server.
Warning: The primary exchange rate server (ecb) failed for Euro (EUR) - trying the secondary exchange rate server.
Warning: The primary exchange rate server (ecb) failed for GB Pound (GBP) - trying the secondary exchange rate server.
Warning: The primary exchange rate server (ecb) failed for Canadian Dollar (CAD) - trying the secondary exchange rate server.
on original site and the two test sites.

Looking for common denominator so contacted hosting company but their response: Our server wouldn't control any of those values, its more of a development issue as it relates directly with the database and configuration files.

Primary is set to ecb, but any other settings in admin that need to be changed? or any other possible solutions?
Thanks for any help.

4 Aug 2017, 1:08 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,086
Plugin Contributions:
56

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

Jacksback2:

The upgrade was done by qualified third party, so assume it was done correctly.

Did a test by doing a quick install of Zencart (via Softalucous) on two other hosting accounts with the same hosting company.
Ran "update currencies" and the same error:
Warning: The primary exchange rate server (ecb) failed for US Dollar (USD) - trying the secondary exchange rate server.
Warning: The primary exchange rate server (ecb) failed for Euro (EUR) - trying the secondary exchange rate server.
Warning: The primary exchange rate server (ecb) failed for GB Pound (GBP) - trying the secondary exchange rate server.
Warning: The primary exchange rate server (ecb) failed for Canadian Dollar (CAD) - trying the secondary exchange rate server.
on original site and the two test sites.

Looking for common denominator so contacted hosting company but their response: Our server wouldn't control any of those values, its more of a development issue as it relates directly with the database and configuration files.

Primary is set to ecb, but any other settings in admin that need to be changed? or any other possible solutions?
Thanks for any help.
Getting the same thing here on a Zen Cart 1.5.5a store. The CURL request is receiving a 403 (Access denied), as illustrated in the following dump of the data returned by ECB:

[04-Aug-2017 08:53:51 America/Kentucky/Louisville] PHP Warning:  array (
  0 => '<html lang="en">',
  1 => '<head>',
  2 => '<title>European Central Bank</title>',
  3 => '<style type="text/css"> body{ font-family: "Droid Sans", sans-serif; margin:0; padding:0; background-color: #9099ab; text-align: center; } h1{  font-size:38px; font-weight: normal; color:#003299; }  @media screen and (max-width: 480px) { h1{ font-size: 30px; } }  p { font-size: 15px; line-height: 20px; color: #333; margin-bottom: 20px; }  p.signature{ font-style: italic; color:#DF0101; }  .centredFrame { margin: 0 auto; text-align: center; width: 70%;   } .content{ margin-top:40px; padding:40px; background-color: #fff; border:1px solid #CDE3E0; -moz-border-radius: 20px; border-radius: 20px; } </style>',
  4 => '<link href="http://fonts.googleapis.com/css?family=Droid+Sans" rel="stylesheet" type="text/css">',
  5 => '</head>',
  6 => '<body>',
  7 => '<div class="centredFrame">',
  8 => '<div class="content">',
  9 => '<img src="http://www.ecb.europa.eu/pic_failover/ecb_logo_EN.png">',
  10 => '<h1>A problem occurred while trying to access this page</h1>',
  11 => 'We apologize for any inconvenience this might have caused.',
  12 => '<p class="signature">Reference number: xxx</p>',
  13 => '<p class="signature">HTTP status code: [B]403[/B]</p>',
  14 => '</div>',
  15 => '</div>',
  16 => '</body>',
  17 => '</html>',

I've verified that I can access the ecb rates link directly, so it might be a change that ecb introduced to prevent scraping.

4 Aug 2017, 1:28 PM
#7
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,086
Plugin Contributions:
56

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

Just poking around to see what's up, I made a slight change to /YOUR_ADMIN/includes/functions/localization.php's *doCurlCurrencyRequest *function, adding the line highlighted below and ... I've got currency updates!

Please note that I'm not sure if this is the "correct" solution, but it's one that got the desired results.

  function doCurlCurrencyRequest($method, $url, $vars = '') {
    //echo '-----------------<br />';
    //echo 'URL: ' . $url . ' VARS: ' . $vars . '<br />';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
[B]    curl_setopt($ch, CURLOPT_REFERER, HTTP_CATALOG_SERVER . DIR_WS_CATALOG);[/B]
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

...
4 Aug 2017, 1:46 PM
#8
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

I have not been kept the currencies updated as frequently lately, so I do not know when the issue began here.
zc 1.5.4

Success The exchange rate for US Dollar (USD) was updated successfully via ecb.
Warning Warning: The primary exchange rate server (ecb) failed for Euro (EUR) - trying the secondary exchange rate server.
Error Error: The exchange rate for Euro (EUR) was not updated via boc. Is it a valid currency code?
Warning Warning: The primary exchange rate server (ecb) failed for GB Pound (GBP) - trying the secondary exchange rate server.
Error Error: The exchange rate for GB Pound (GBP) was not updated via boc. Is it a valid currency code?
Warning Warning: The primary exchange rate server (ecb) failed for Canadian Dollar (CAD) - trying the secondary exchange rate server.
Error Error: The exchange rate for Canadian Dollar (CAD) was not updated via boc. Is it a valid currency code?
Warning Warning: The primary exchange rate server (ecb) failed for Australian Dollar (AUD) - trying the secondary exchange rate server.
Error Error: The exchange rate for Australian Dollar (AUD) was not updated via boc. Is it a valid currency code?
Warning Warning: The primary exchange rate server (ecb) failed for New Zealand Dollar (NZD) - trying the secondary exchange rate server.
Error Error: The exchange rate for New Zealand Dollar (NZD) was not updated via boc. Is it a valid currency code?

4 Aug 2017, 1:57 PM
#9
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

myDEBUGadmin
repeated several times

[04-Aug-2017 06:49:27 America/Los_Angeles] PHP Warning:  Division by zero in /home/chainwea/public_html/9nd6Q536/includes/functions/localization.php on line 37
[04-Aug-2017 06:49:27 America/Los_Angeles] Request URI: /9nd6Q536/currencies.php?page=1&cID=5&action=update_currencies, IP address: XXX.231.113.241
#1  quote_ecb_currency() called at [/home/chainwea/public_html/XXX/currencies.php:99]

[04-Aug-2017 06:49:27 America/Los_Angeles] PHP Warning:  Division by zero in /home/chainwea/public_html/XXX/includes/functions/localization.php on line 37
[04-Aug-2017 06:49:27 America/Los_Angeles] Request URI: /XXX/currencies.php?page=1&cID=5&action=update_currencies, IP address: XXX.231.113.241
#1  quote_boc_currency() called at [/home/chainwea/public_html/XXX/currencies.php:105]

[04-Aug-2017 06:49:27 America/Los_Angeles] PHP Warning:  Division by zero in /home/chainwea/public_html/XXX/includes/functions/localization.php on line 64
4 Aug 2017, 10:07 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

Jacksback2:

Having this exact issue after recent upgrade to V1.5.5e. How do I check database and how to resolve?
Okay, so actually, your issue is NOT "exactly" the same.

The first person posting was getting "Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed".

But yours is actually naming the primary currency exchange server code (you didn't reveal this in your very brief "me too" post). Completely different reason behind that.

If it was actually still saying "CURRENCY_SERVER_PRIMARY" instead of the name of the server, then it would indeed have been an upgrade issue. Hence the suggestion to look in that direction.

Yours is a different matter. You're not getting ECB rates because ECB recently enforced some rules on their database, apparently to reject incoming requests that might look like bots that are scraping data. I've run into the same issue on other servers, from various geo locations and various hosting companies.

There are several suggested workarounds:
a) lat9's suggestion above to specify a referrer.
b) change your primary currency server to the built-in alternate of BOC (may wanna update to the latest /admin/includes/functions/localization.php from v1.5.6)
c) add a different currency exchange source using one of the available plugins (I recommend OpenExchangeRates, but you need to sign up for free api access as explained in the plugin.)

5 Aug 2017, 1:20 PM
#11
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

lat9:

Just poking around to see what's up, I made a slight change to /YOUR_ADMIN/includes/functions/localization.php's *doCurlCurrencyRequest *function, adding the line highlighted below and ... I've got currency updates!

Please note that I'm not sure if this is the "correct" solution, but it's one that got the desired results.

function doCurlCurrencyRequest($method, $url, $vars = '') {
//echo '-----------------<br />';
//echo 'URL: ' . $url . ' VARS: ' . $vars . '<br />';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
[B] curl_setopt($ch, CURLOPT_REFERER, HTTP_CATALOG_SERVER . DIR_WS_CATALOG);[/B]
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

...


TNX Cindy,
That took care of the issue in zc 1.5.4
9 Aug 2017, 8:03 AM
#12
jacksback2 avatar

jacksback2

New Zenner

Join Date:
Jun 2010
Posts:
10
Plugin Contributions:
0

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

Just tried Lat9's fix and it worked as well. Great work and big thank you.

9 Aug 2017, 3:33 PM
#13
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

FYI: lat9's fix is now built-in to v1.5.6

13 Sep 2017, 12:37 PM
#14
thunder2010 avatar

thunder2010

New Zenner

Join Date:
Aug 2010
Location:
Egypt - USA
Posts:
86
Plugin Contributions:
0

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

DrByte:

There are several suggested workarounds:
a) lat9's suggestion above to specify a referrer.
b) change your primary currency server to the built-in alternate of BOC (may wanna update to the latest /admin/includes/functions/localization.php from v1.5.6)
c) add a different currency exchange source using one of the available plugins (I recommend OpenExchangeRates, but you need to sign up for free api access as explained in the plugin.)

I used solution a) and it work very good for me, But when i change my default currency to some thing else than USD it set the default currency to 1 and miss all other currency.
Then i try solution C) and it work very good with all.

18 Sep 2017, 7:24 PM
#15
spminis avatar

spminis

Zen Follower

Join Date:
Feb 2015
Location:
USA
Posts:
194
Plugin Contributions:
0

Re: Warning: The primary exchange rate server (CURRENCY_SERVER_PRIMARY) failed for US

lat9:

Just poking around to see what's up, I made a slight change to /YOUR_ADMIN/includes/functions/localization.php's *doCurlCurrencyRequest *function, adding the line highlighted below and ... I've got currency updates!

Please note that I'm not sure if this is the "correct" solution, but it's one that got the desired results.

function doCurlCurrencyRequest($method, $url, $vars = '') {
//echo '-----------------<br />';
//echo 'URL: ' . $url . ' VARS: ' . $vars . '<br />';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
[B] curl_setopt($ch, CURLOPT_REFERER, HTTP_CATALOG_SERVER . DIR_WS_CATALOG);[/B]
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

...


Worked for me!  Thanks so much

Carol