Upgraded from 3.90 to 4.20, and everything works except the USPS plugin? USPS (A task was canceled.)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi,

I finally figured out the upgrade process to get from 3.90 to 4.20 and everything works except the most important plugin on the entire store, the USPS plugin. It works perfectly if I change the site back to the 3.90 site with the original 3.90 database.

In the 4.20 upgraded site/database, when I put an item in my cart and go to the cart page and try to use the shipping calculator, all it does is show this message:

=================================================
Shipping (USPS (US Postal Service)). USPS Service is currently unavailable, try again later. One or more errors occurred. (A task was canceled.)  
=================================================

All the 4.20 site logs show this:
=================================================
Warning  Shipping (USPS (US Postal Service)). USPS Service is currently unavailable, try again later. One or more errors occurred. (A task was canceled.)  

Error  USPS Service is currently unavailable, try again later. One or more errors occurred. (A task was canceled.)
=================================================

They problem is not my USPS credentials that I can tell because I'm using the same exact settings/credentials in both the 3.90 and 4.20 sites, quadruple checked, and when I switch over to the 3.90 site the shipping plugin works correctly instantly.

I've tried to run through the same upgrade process on a backup database by cloning the 3.20 database, then re-run all the database upgrade scripts from 3.90 > 4.0 > 4.1 > 4.2 and replaced all the site files as required (setting.txt >.dataSettings.json and InstalledPlugins.txt > plugins.json) and the entire site comes up and all customer and product data is there etc but still hit the same USPS plugin issue.

Any idea what the problem could be or how to get more info out of the system to figure out what the problem really is?
4 years ago
I just went through the upgrade process again and the first time that I go to the 4.20 site and try to calculate shipping in my cart IT WORKS!  

But every time after that all I get is "USPS Service is currently unavailable, try again later. One or more errors occurred. (A task was canceled.)"

What am I missing?
4 years ago
I just tried to uninstall the USPS plugin, then deleted it. Then searched for and downloaded the latest USPS plugin and tried to upload it but got the message:

===================================================
Cannot create 'h:\root\home\www\mystore42\Plugins\Shipping.USPS\Views' because a file or directory with the same name already exists.
===================================================

So I deleted the 'Shipping.USPS' folder completely and tried to upload the plugin again but I get the same error message.

It's creating the \Shipping.USPS and \Shipping.USPS\Views directories on the server, but then it stops and the Views folder is empty and no other files exist in the \Shipping.USPS directory.

Why won't the plugin install? How can I re-install it?
4 years ago
Ok for anyone that runs into this problem, this is what I did to fix it:

1. Backup the 3.90 DB
2. Run the update scripts in order from 3.90 > 4.0, then 4.0 > 4.1, then 4.1 > 4.2. Note that if you have any special modules/themes that reference database objects, you may need to run update scripts for those things, which you can usually get from the plugin/theme provider.
3. Then in a new directory, upload all the Nopcommerce 4.20 files.
4. Then copy the following files from the v3.90 site directory
         \App_Data\Settings.txt
         \App_Data\InstalledPlugins.txt
5. Rename file setting.txt to .dataSettings.json and InstalledPlugins.txt to plugins.json
6. Switch your website to use the new files in the new 4.20 site directory using your web host's control panel.
7. Go to your sites homepage in your web browser and it should come up normally.

To fix the USPS plugin issue:
1. Go to the Nopcommerce admin panel and go to Configuration > Shipping > Shipping providers and click 'Configure' and COPY THE USERNAME AND PASSWORD and keep it in a safe place.
2. Then go to Configuration > Plugins > Local Plugins and UNINSTALL the USPS plugin. (you'll need to click the 'Restart site/services' button to complete the uninstall)
3. Then DELETE the USPS plugin on the Local Plugins page by clicking DELETE. (you'll need to click the 'Restart site/services' button to complete the delete)
4. Then go to Configuration > Plugins > All Plugins and Themes and search for 'USPS' and click search. Then click on the plugin and it will take you to a download page. Download the plugin zip file.
5. Then UNZIP THE PLUGIN and locate the 'nopCommerce 4.20' folder. Inside that folder is the 'Shipping.USPS' folder.
6. Zip up ONLY the 'Shipping.USPS' folder and all the files that it contains.
7. Use your web host's file manager (or use FTP) to upload the zip file to your websites 4.20 site folder to the /Plugins/ directory.
8. Then use your web hosts file manager to UNZIP the zip file to the /Plugins/ directory. (Note: If the "Shipping.USPS" folder already exists in the /Plugins/ directory, then you may have to delete it first before unzipping the zip file.)
9. Once the file is unzipped, the "Shipping.USPS" folder should appear in the /Plugins/ directory with all the other usps code files inside it.
10. Then go to your Nopcommerce admin panel and go to Configuration > Plugins > Local Plugins and INSTALL the USPS plugin. (you'll need to click the 'Restart site/services' button to complete the install)
11. Then once it's installed, then go to Configuration > Shipping > Shipping providers and click 'Configure' and ADD THE USERNAME AND PASSWORD that you saved earlier and click SAVE.

That should get the USPS plugin working normally again.
4 years ago
Well, that seemed to fix it.... but now its still happening.

I think it must be a timeout in the USPS plugin or a Nopcommerce service timeout somewhere or maybe even a web server process timeout that causes the USPS lookup process to be canceled if it takes over 5 seconds to get a response from the USPS API service or something.
4 years ago
I've been getting the same error in the last few weeks also. It seems to come and go but mostly it doesn't work. Can someone from nopCommerce look into the problem as it's killing my business not being able to offer USPS shipping to my customers. Appreciate it. Thanks.
4 years ago
Thanks. We'll investigate it.
4 years ago
SkierHiker wrote:
...mostly it doesn't work...

Yes, 5 seconds is probably not enough (and this should be made a Setting), but if it is happening to you frequently, and yet we're not seeing many other complaints about it, then it could be an 'infrastructure' problem on your (host?) network.

\Plugins\Nop.Plugin.Shipping.USPS\Services\USPSHttpClient.cs
        public USPSHttpClient(HttpClient client, USPSSettings uspsSettings)
...
            client.Timeout = TimeSpan.FromMilliseconds(5000);
...

        public async Task<RateResponse> GetRatesAsync(...
            var responseStream = await _httpClient.GetStreamAsync($"?API={apiKey}&XML={requestString}");
4 years ago
That seemed to be it. I changed it to 30 seconds (to be safe), added some debug log entries and I found that the response time is between 10 and 20 seconds. It has to be USPS as UPS and FedEx are normal.
4 years ago
SkierHiker wrote:
That seemed to be it. I changed it to 30 seconds (to be safe), added some debug log entries and I found that the response time is between 10 and 20 seconds. It has to be USPS as UPS and FedEx are normal.


Thanks for your test results!

Is there a way or db variable to change that timeout value in the no-source version or would I have to convert my entire site to the source code version and re-deploy?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.