open.connection 地理编码功能失败
open.connection failing in geocoding function
我目前正在 运行 进行地理编码功能(使用 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}
我不太确定如何处理这些信息。据我所知,这似乎是某种 security/firewall 问题。我应该如何为 R 授予 运行 此功能所需的权限?
我 运行宁 Windows 10 Windows 后卫 antivirus/firewall。作为参考,这是我用于地理编码的函数:
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))
}
}
我能够通过使用一个副词来解决这个问题,我在另一个地理编码函数中使用了这个副词,该函数在无法提供结果时尝试 运行 该函数 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
}
}
摘自 .
我目前正在 运行 进行地理编码功能(使用 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}
我不太确定如何处理这些信息。据我所知,这似乎是某种 security/firewall 问题。我应该如何为 R 授予 运行 此功能所需的权限?
我 运行宁 Windows 10 Windows 后卫 antivirus/firewall。作为参考,这是我用于地理编码的函数:
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))
}
}
我能够通过使用一个副词来解决这个问题,我在另一个地理编码函数中使用了这个副词,该函数在无法提供结果时尝试 运行 该函数 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
}
}
摘自