banboo-data / RBingAds

R API wrapper for the Bing Ads API
Other
2 stars 0 forks source link

Error: TLS v1 Alert Protocol Version #27

Open jaret-statbid opened 3 years ago

jaret-statbid commented 3 years ago

Hi Johannes,

Thank you so much for your work on this project (among others). It's been incredibly valuable to me!

I've been using the RBingAds package for many months now, but just yesterday, I started receiving a new error when running my usual code:

load_bing_data(bing_auth = bing_auth,
                               account_id = paste(accountId),
                               report = "CampaignPerformanceReport",
                               columns = c("CampaignName","Clicks"),
                               start = paste("2021-06-01"),
                               end = paste("2021-06-30"))

"Error in function (type, msg, asError = TRUE) : error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version"

I tried similar, simple queries, using different Bing accounts I have access to, as well as on 2 different PCs, and still always got the same error.

I dug around in the source code enough that I think I may have narrowed down the source of the error to the curlPerform call in the get_report_id function:

  curlPerform(
    url = url,
    httpheader = headerFields,
    postfields = body,
    writefunction = h$update
  )

This call alone produces the same error message. Noticing the "tlsv1 alert protocol version" message, I wonder if a no longer supported TLS version is being used? I see that curlPerform has an sslversion option, which I tried changing the value of, but when selecting sslversion = 5, 6, or 7, I just get an "Unsupported SSL protocol version" error instead.

I'm a little lost for direction from here. Any help or insights you could share would be greatly appreciated. Thank you.

sshemtov commented 3 years ago

@jburkhardt this is also not working for me. Are you able to look into this? If not let us know so we can find a workaround. Thanks!

sshemtov commented 3 years ago

@jaret-statbid I ended up rebuilding a data grabber in Python using the BingAds sdk supported by Microsoft. It wasn't that hard, hardest part was the authorization.

R.I.P. RBingAds

jburkhardt commented 3 years ago

Hi @jaret-statbid @sshemtov Thank you for using the package and reporting this issue. I will look into it soon!

luisccmm commented 2 years ago

Same error, and no solution

jburkhardt commented 2 years ago

Hi @jaret-statbid @sshemtov @luisccmm ,

I just tested the package on mac OS and everything seems to work fine! The authentication process works fine and I am able to pull data from the Bing Ads API.

@jaret-statbid writes something about testing on PC. Please provide the following information since I cannot reproduce the error:

Moreover, please make sure that you have the following R packages installed:

Additionaly, please check if your Bing refresh token is still valid, since the token expires from time to time. Try to authenticate with:

bing_auth <- authenticate(
    save = T,
    path = ".bingauth",
    gitignore = T
)

Print the bing_auth object to the console and check if it contains any error messages.

Let me know if you succeed!

csadagents commented 2 years ago

Hi @jburkhardt ,

I currently have the same Problem runnig R (4.1.2) on a Windows machine (all required packages are up to date). Since my code runs without problems on my Linux machine, I looked for differences and found the following:

RCurl on Windows runs with OpenSSL 1.0.0, which does not support the newer TLS standards required by Bing. At least OpenSSL 1.0.1 is required. Do you have a suggestion to solve the problem?

Best regards, CS

jburkhardt commented 2 years ago

@csadagents Thanks for the clarification! Isn't it ironic: the RBingAds package works on Lunix and Mac, but not on Windows :) We will revise the package and take this into consideration.

csadagents commented 2 years ago

@jburkhardt, in the meantime I found a quick workaround, but it is not very stable. It also doesn't work well in combination with the package renv. I simply took the Windows r-devel binary (RCurl_1.98-1.6.zip) from https://cran.r-project.org/web/packages/RCurl/index.html and installed it using install.packages("Filepath/RCurl_1.98-1.6.zip", repos = NULL, type = "win.binary"). RCurl::curlVersion()$ssl_version then displays the OpenSSL version "OpenSSL/1.1.1k (Schannel)" and my script is executed without errors. As already mentioned, this fix causes problems again elsewhere. So I'm happy if you can get your package more stable. Thanks in any case for the quick reply!