I have created an app deployed on shinyapps.io.
From this app, I can click a button which triggers a call to an API written with plumber (deployed on AWS):
observeEvent(input$button_clicked, {
print("calculate called")
res_calculate <- httr::POST(
url = "http://myapi.amazonaws.com",
path = "calculate",
timeout(2400)
)
print("calculate returned")
})
On the API side, I have the following:
#' Get data from a data base, does a long calculation and returns the result
#'
#' @export
#'
#' @post /calculate
calculate <- function() {
print("calculate started")
# Here is a long calculation (~20 min)
Sys.sleep(1200)
res <- 1
print("calculate ended")
return(res)
}
When I click on the button, I get on the UI side "calculate called"
, on the logs of my API, I can see
"calculate started"
then 20 minutes pass and I get "calculate ended"
but I never get "calculate returned"
on the UI. Neither do I get a timeout error. Nothing. The Shiny app is kind of stuck for ever in a busy state.
I have shorter API calls from my Shiny app that go smoothly. (I will try to determine the time limit from which I get this problem.)
I am looking for hints on how to config httr:POST
so as to solve this problem.