webchem icon indicating copy to clipboard operation
webchem copied to clipboard

get_csid() always returning error "Service not available. Returning NA."

Open CesarIsguerra opened this issue 3 years ago • 8 comments

Hi. I'm having a permanent "Service not available. Returning NA." error result when using get_csid(). I was trying with a list of substances but found the issue remains even if I search for a single substance, as in:

SustFaltantes_cs <- get_csid("3-Cyclohexene-1-methanol,.alpha.,.alpha.,4-trimethyl-, (S)-", apikey = 'Lt1Ah22zVgGvn2Lgn2UzH8zSAlnB9ZCr')

The apikey is new and I have no problems with other databases get-id functions. The error message includes "Error in get_csid("3-Cyclohexene-1-methanol,.alpha.,.alpha.,4-trimethyl-, (S)-", :". Thanks in advance for your orientation.

CesarIsguerra avatar Aug 01 '22 17:08 CesarIsguerra

Hi @CesarIsguerra thanks for opening this issue. I could reproduce your output, but I think the returned csid (NA) is consistent with the web interface output which also returns zero hits. Do you agree with my assessment?

It seems both the get_csid() function in webchem and your apikey is working fine, e.g. get_csid("caffeine", apikey = 'Lt1Ah22zVgGvn2Lgn2UzH8zSAlnB9ZCr', verbose = TRUE) returns a valid csid for caffeine, 2424. Can you please confirm that other compounds work on your end as well?

stitam avatar Aug 02 '22 06:08 stitam

Thank you, Tamás, for replying. I've tried the "caffeine" search and still received the "Service not available. Returning NA." message imagen (Also, the list of substances I first tried get_csid() to search for contained some names that I'm pretty sure ChemSpider would have to acknowledge). So, I understand you did the "caffeine" search with my API key and had success. It makes me wonder: when I tried the initial batch search I inadvertently ran the function without storing the result in a variable and it seemed to be working, so after quite a few minutes (the list's length was ca. 800), when I realized the absence of a storing variable in my command, I stopped execution. Then I retried using a storing variable and the error message came to never leave again (as in the "caffeine" search I did). To make sure it was not a matter of having a worn-out API key, I created a new one (from a new account as well; the one I shared here) with no success. That's when I started this thread. I mention all this because it may mean something to you... or not.

CesarIsguerra avatar Aug 02 '22 22:08 CesarIsguerra

Not yet, but I'm working on it :) This error is strange, can you please post your webchem version number (should be 1.1.3) and also check whether ping_service("cs") returns TRUE?

stitam avatar Aug 03 '22 12:08 stitam

imagen imagen The versions are right but ping_service("cs") effectively returns FALSE. There is a problem alright...

CesarIsguerra avatar Aug 03 '22 14:08 CesarIsguerra

Okay, I think I have a clue, can you ping the service from a separate network, maybe fire up a vpn if you have one?

stitam avatar Aug 03 '22 14:08 stitam

Sorry, I didn't know much about VPNs. I google-searched and activated a free vpn service (Proton) but still got the non-availability error message. I will retry when I'm out of home though, since it may be that some IP address related to me or to my internet service provider was blocked by ChemSpider service, right? Or maybe I'm a little confused aboout what you're suspecting?

CesarIsguerra avatar Aug 03 '22 16:08 CesarIsguerra

That's right, the point is, use a different IP address than the one you used for the 800 long ChemSpider query.

I realised a line of code which limits the speed of the queries is missing from this function (it's there in most webchem functions). If you post queries too quickly, some services temporarily ban your IP. This is clearly a bug on our end, sorry (it's unclear why it hasn't come up yet). Until the fix is implemented, you can e.g. post your queries in a for cycle and add Sys.sleep(0.2) in each iteration. Alternatively, you can try the PubChem functions? I can usually get what I need with get_cid() and pc_sect().

stitam avatar Aug 03 '22 17:08 stitam

Ok. I'll try the alternatives you mention. Thank you so much for your help, Tamás.

CesarIsguerra avatar Aug 03 '22 18:08 CesarIsguerra