Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create tunnel to Presto web UI #40

Open
copernican opened this issue May 26, 2020 · 0 comments
Open

Cannot create tunnel to Presto web UI #40

copernican opened this issue May 26, 2020 · 0 comments

Comments

@copernican
Copy link

I am trying to connect to a web server (in this case, the status page for Presto database) that is accessible via SSH and am having trouble creating a tunnel. Creating the tunnel by calling ssh directly works (note that host and port are in a hidden chunk of the reprex):

pid <- sys::exec_background(
  "ssh",
  args = c(host, "-L", glue::glue("{port}:localhost:{port}"), "-N")
)
Sys.sleep(2)  # allow tunnel to be created

res <- httr::GET(glue::glue("http://localhost:{port}/ui/"))
httr::status_code(res)
#> [1] 200

tools::pskill(pid)

Created on 2020-05-26 by the reprex package (v0.3.0)

But creating the tunnel with ssh_tunnel() does not work.

cmd <- glue::glue(
  'session <- ssh::ssh_connect("{host}"); ',
  'ssh::ssh_tunnel(session, port = {port}, target = "{host}:{port}")'
)
pid <- sys::exec_background("R", c("-e", cmd))
Sys.sleep(5)

res <- httr::GET(glue::glue("http://localhost:{port}/ui/"))
#> Error in curl::curl_fetch_memory(url, handle = handle): Recv failure: Connection reset by peer
httr::status_code(res)
#> Error in httr::status_code(res): object 'res' not found

tools::pskill(pid)

Created on 2020-05-26 by the reprex package (v0.3.0)

The error from GET() is more descriptive when run interactively:

Error: libssh failure at 'channel_open_forward': Channel opening failure: channel 43 error (2) Connection refused
Execution halted
Warning message:
Disconnecting from unused ssh session. Please use ssh_disconnect()
 
Error in curl::curl_fetch_memory(url, handle = handle) : 
  Recv failure: Connection reset by peer

I would have expected the ssh_tunnel() approach to be equivalent to directly calling ssh. Curiously, I can use the ssh_tunnel() approach to connect to a different host and service (RStudio Server) and get the message

/ Tunneled 448 bytes...tunnel closed!

One possibility is that ssh_tunnel() eventually creates the tunnel using the string "localhost", which may be handled oddly by Presto? It seems that MySQL, for example, treats localhost differently from 127.0.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant