【问题标题】:open.connection failing in geocoding function地理编码功能中的 open.connection 失败
【发布时间】:2018-01-18 19:24:15
【问题描述】:

我目前正在运行地理编码功能(使用googleway 包中的google_places 功能)。该函数会运行一段时间(我有将近 3k 个位置),然后抛出以下错误:

Error in open.connection(con, "rb") : 
  schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326) - This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed). More detail may be available in the Windows System event log.

查阅了系统事件日志,发现如下信息:

The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID 
{9BA05972-F6A8-11CF-A442-00A0C90A8F39}
 and APPID 
{9BA05972-F6A8-11CF-A442-00A0C90A8F39}

我不太确定如何处理这些信息。据我所知,这似乎是某种安全/防火墙问题。我应该如何为 R 授予运行此功能所需的权限?

我正在运行带有 Windows Defender 作为防病毒/防火墙的 Windows 10。作为参考,这是我用于地理编码的函数:

metro.locater <- function(lat, lon){

  library(googleway)

  #putting latitude and longitude into the same vector
  latlon <- c(lat, lon)

  #getting places result
  res <- google_places(location = latlon, 
                       place_type = "subway_station", radius = 50000,
                       rankby="distance",
                       key = "myKey")
  #condition handling
  if(res$status == 'OK'){
  closest <- res$results[1:3, ]

  return(closest)} else {
  try(return(res$status))
  }

}

【问题讨论】:

    标签: r permissions google-places-api handshake windows-firewall


    【解决方案1】:

    我能够通过使用与另一个地理编码函数一起使用的副词来解决此问题,该函数在未能提供结果时尝试运行该函数 5 次。鉴于这有效,这似乎只是一个暂时性错误而不是系统性问题。

    我使用的副词:

    safely <- function(fn, ..., max_attempts = 5) {
      function(...) {
        this_env <- environment()
        for(i in seq_len(max_attempts)) {
          ok <- tryCatch({
              assign("result", fn(...), envir = this_env)
              TRUE
            },
            error = function(e) {
              FALSE
            }
          )
          if(ok) {
            return(this_env$result)
          }
        }
        msg <- sprintf(
          "%s failed after %d tries; returning NULL.",
          deparse(match.call()),
          max_attempts
        )
        warning(msg)
        NULL
      }
    }
    

    取自Repeating values in loop until error disappears

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-29
      • 2018-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多