Skip to content

Serving a shiny app #51

@tomsing1

Description

@tomsing1

Thanks a lot for this great R package! I am new to plumber(2) and am experimenting with serving a shiny app.
I copied the app.R example app into a shiny subdirectory and defined the following plumber.R file:

#* @shiny /my_app/
shiny::shinyAppDir("./shiny")

When I start the API with

library(plumber2)

pa <- plumber2::api("plumber.R")
pa |> plumber2::api_run(showcase = FALSE)

I get the following message, confirming that the server is running:

plumber2 server started at http://127.0.0.1:8080

When I navigate to http://127.0.0.1:8080/my_app/ in chrome, I see the title and the interactive slider of the app, but no plot. When I reload the page in the browser, I get the following error in the R console:

Error in websocket callback: A payload contained invalid data
Error executing onWSMessage (1011)

I might be misunderstanding how shiny apps are intended to be used with plumber2. Perhaps you can point me in the right direction? The minimal example on the help page for api_shiny() was helpful, but I am not sure if I should expect a fully interactive plot?

Many thanks for any pointers!

Session Information

R version 4.5.1 (2025-06-13)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.6.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats graphics grDevices datasets utils methods base

other attached packages:
[1] shiny_1.11.1 plumber2_0.1.0

loaded via a namespace (and not attached):
[1] xfun_0.53 bslib_0.9.0 processx_3.8.6 websocket_1.4.4 firestorm_0.1.0
[6] callr_3.7.6 ps_1.9.1 vctrs_0.6.5 tools_4.5.1 curl_7.0.0
[11] parallel_4.5.1 tibble_3.3.0 pkgconfig_2.0.3 mirai_2.5.0 lifecycle_1.0.4
[16] compiler_4.5.1 stringr_1.5.2 textshaping_1.0.3 brio_1.1.5 codetools_0.2-20
[21] brotli_1.3.2 sodium_1.4.0 httpuv_1.6.16 routr_1.0.0 htmltools_0.5.8.1
[26] sass_0.4.10 later_1.4.4 pillar_1.11.1 jquerylib_0.1.4 cachem_1.1.0
[31] mime_0.13 parallelly_1.45.1 digest_0.6.37 stringi_1.8.7 future_1.67.0
[36] purrr_1.1.0 listenv_0.9.1 fastmap_1.2.0 cli_3.6.5 magrittr_2.0.4
[41] base64enc_0.1-3 triebeard_0.4.1 withr_3.0.2 promises_1.3.3 roxygen2_7.3.3
[46] globals_0.18.0 ragg_1.5.0 reqres_1.0.0 webutils_1.2.2 memoise_2.0.1
[51] evaluate_1.0.5 knitr_1.50 rlang_1.1.6 urltools_1.7.3.1 Rcpp_1.1.0
[56] nanonext_1.7.0 xtable_1.8-4 glue_1.8.0 xml2_1.4.0 renv_1.1.5
[61] svglite_2.2.1 fiery_1.3.0 firesafety_0.1.0 jsonlite_2.0.0 R6_2.6.1
[66] systemfonts_1.2.3 fs_1.6.6 rapidoc_9.3.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions