51Degrees / Device-Detection

THE Fastest and most Accurate device detection for C / PHP / Perl / Python and Node.js - professionally maintained device data
https://51degrees.com/device-detection
Other
112 stars 46 forks source link

Automatic update not working #23

Closed ashishnetworks closed 6 years ago

ashishnetworks commented 6 years ago

Following is my provider's config JSON of mine in Node.js var config = { "Licence":"MyLisenceKey-I-Put-here", "dataFile" : require('../db-file'), "poolSize" : 50, "cacheSize" : 5000 };

But automatic update doesn't seem to be working. Do I need to change anything else? actually, I have just bought the licence so I'm following the documentation and not very sure if I'm missing any part

Joseph51D commented 6 years ago

Hi @ashishnetworks

Due to our customer base being predominantly American, we operate using American English. In this case the problem is likely due to the spelling of the "License" field.

Try using "License":"Your-LicenseKey" instead.

Kind regards, Joe

ashishnetworks commented 6 years ago

thanks Joe for the reply, I just tried changing the spelling of key but that doesn't seem to be working either. I have been waiting for half an hour for the file to be replaced by newer one, but nothing is happening. I'm also monitoring network activities but I don't feel anything is getting downloaded

Joseph51D commented 6 years ago

Hi Ashish, thanks for getting back.

The update services uses an event emitter to log what's going on. Can you enable logging in your app and provide me with the output?

var fiftyonedegrees = require("fiftyonedegreescore");

fiftyonedegrees.log.on('info', function(err){
    console.log(err)
});

See this section of the Readme for more details: https://github.com/51Degrees/Device-Detection/tree/master/node.js#logging

The API will take a least half an hour after starting before an update is attempted.

Kind regards, Joe

ashishnetworks commented 6 years ago

okay thank you for the information, I have updated my code with the code given by you. So far there is no output from the code. I will update you once I get any output on the screen. This time I will wait for at least an hour before I conclude anything

ashishnetworks commented 6 years ago

Hi Joe, I got the following output after around half an hour

[1] Could not update the data file reason: The license key(s) provided were invalid. See https://51degrees.com/compare-data-options to acquire valid license keys.

I have doubled checked my license key value and it is exactly alike the one which is shown in my account. Could it be related to my account type? because I have purchased a premium package which provides the weekly update and not daily ones. But even if it gives the weekly update, shouldn't it update the file if the current DB file is outdated?

Joseph51D commented 6 years ago

Hi Ashish,

If the data file is out of date then the API will try to update the data file provided there is a valid license key configured. Here the API has logged the the key is invalid, this may simply be due to some invalid characters.

Did you receive an email containing your license key? If so please try using the one contained in the email rather than the one on the account page. If the update still fails then please contact support@51degrees.com for further assistance with licensing.

Kind regards, Joe

ashishnetworks commented 6 years ago

Thanks again, I will check if the key matches with my key received on email. Anyways one more thing I thought you should be knowing that my existing DB file is the one which is provided in the light version, and I'm expecting that my light version's DB file shall be replaced by premium version's file. Hope I'm not expecting something unrealistic.

ashishnetworks commented 6 years ago

Hi I tried replacing my License key with the one received on email. This time I received some different error

[1] Could not update the data file reason: An error occurred fetching the data file. Try again incase the error is temporary, or validate license key and network configuration.

When I closely observed the code of update.js file in fiftyonedegreesscore library, it seems that I'm receiving 404 HTTP response code in return for download response. And one more thing I found to be pretty confusing that there was following variable set var product = 'Lite'; Does that mean your updating code is still considering my product type to be Lite and not premium and may be why I'm not receiving any downloadable DB? Maybe I'm mistaken in using the same library which I would use while testing with Lite DB, so do I need to update my library with any newer version specifically developed for users of premium version?

ashishnetworks commented 6 years ago

I resolved the problem actually, the problem was that I needed to have an older version of a real premium database file in my database directory. I was expecting that my older Lite version's DB file will be updated to newer premium version. But when I relooked into your library's updating code I realised that it checks the first byte of available DB file to figure out the type of my product and since I was using my lighter versions DB file it was considering my product type to be of Lite and so it was trying to download a DB file with product name as Lite and my real License key which was giving it 404 error.

Joseph51D commented 6 years ago

Hi @ashishnetworks

Glad you got it working! If you have any further issues, please don't hesitate to get in touch.

Regards, Joe