{"action":"created","issue":{"url":"https://api.github.com/repos/rstudio/shiny-server/issues/248","repository_url":"https://api.github.com/repos/rstudio/shiny-server","labels_url":"https://api.github.com/repos/rstudio/shiny-server/issues/248/labels{/name}","comments_url":"https://api.github.com/repos/rstudio/shiny-server/issues/248/comments","events_url":"https://api.github.com/repos/rstudio/shiny-server/issues/248/events","html_url":"https://github.com/rstudio/shiny-server/pull/248","id":180196901,"number":248,"title":"Don't return reused connection from robustify()","user":{"login":"jcheng5","id":129551,"avatar_url":"https://avatars.githubusercontent.com/u/129551?v=3","gravatar_id":"","url":"https://api.github.com/users/jcheng5","html_url":"https://github.com/jcheng5","followers_url":"https://api.github.com/users/jcheng5/followers","following_url":"https://api.github.com/users/jcheng5/following{/other_user}","gists_url":"https://api.github.com/users/jcheng5/gists{/gist_id}","starred_url":"https://api.github.com/users/jcheng5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcheng5/subscriptions","organizations_url":"https://api.github.com/users/jcheng5/orgs","repos_url":"https://api.github.com/users/jcheng5/repos","events_url":"https://api.github.com/users/jcheng5/events{/privacy}","received_events_url":"https://api.github.com/users/jcheng5/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-30T00:48:41Z","updated_at":"2016-09-30T16:34:11Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rstudio/shiny-server/pulls/248","html_url":"https://github.com/rstudio/shiny-server/pull/248","diff_url":"https://github.com/rstudio/shiny-server/pull/248.diff","patch_url":"https://github.com/rstudio/shiny-server/pull/248.patch"},"body":"(This is a change that was in shiny-server-pro since January.)\r\n\r\nWhen a reconnection occurs, there's no need in lib/proxy/sockjs.js\r\nto call onMultiplexConnect; that logic has already been called on\r\nthe robustConn object, the first time it was returned from robustify.\r\n\r\nIt turns out that most times this doesn't make a difference, maybe\r\nbecause it's unlikely after a reconnect for another multiplex\r\nchannel to connect itself (i.e. a new subapp appears); most Shiny\r\napps either don't have subapps, or only load subapps during startup.\r\nOtherwise I think it's likely we would have seen handleMultiplexChannel\r\ncalled multiple times on a single channel.\r\n\r\nHere's a sample app that will demonstrate the bad behavior. Start\r\nshiny-server with SHINY_LOG_LEVEL=TRACE; load the app in a browser;\r\nin the JS console, run \\__shinyserverdebug__.disconnect(); then hit\r\nthe Go button. Without this fix, each time you hit Go, you'll see the\r\nnumber of websocket connections go up by *two*, not one. With this\r\nfix, you'll see that the number of connections just goes up by one.\r\nThe problem is more than just too many connections being used. If\r\nthe actions of the subapp have side effects, you may actually get\r\nincorrect results. Granted we are talking about a severe edge case\r\nof an edge case, but it's theoretically possible.\r\n\r\n```\r\nlibrary(shiny)\r\n\r\nui <- fluidPage(\r\n  actionButton(\"go\", \"Go\"),\r\n  uiOutput(\"ui\")\r\n)\r\n\r\nserver <- function(input, output, session) {\r\n  output$ui <- renderUI({\r\n    req(input$go)\r\n    htmltools::as.tags(shinyAppDir(system.file(\"examples/01_hello\", package=\"shiny\")))\r\n  })\r\n}\r\n\r\nshinyApp(ui, server)\r\n```"},"comment":{"url":"https://api.github.com/repos/rstudio/shiny-server/issues/comments/250791288","html_url":"https://github.com/rstudio/shiny-server/pull/248#issuecomment-250791288","issue_url":"https://api.github.com/repos/rstudio/shiny-server/issues/248","id":250791288,"user":{"login":"trestletech","id":1593639,"avatar_url":"https://avatars.githubusercontent.com/u/1593639?v=3","gravatar_id":"","url":"https://api.github.com/users/trestletech","html_url":"https://github.com/trestletech","followers_url":"https://api.github.com/users/trestletech/followers","following_url":"https://api.github.com/users/trestletech/following{/other_user}","gists_url":"https://api.github.com/users/trestletech/gists{/gist_id}","starred_url":"https://api.github.com/users/trestletech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trestletech/subscriptions","organizations_url":"https://api.github.com/users/trestletech/orgs","repos_url":"https://api.github.com/users/trestletech/repos","events_url":"https://api.github.com/users/trestletech/events{/privacy}","received_events_url":"https://api.github.com/users/trestletech/received_events","type":"User","site_admin":false},"created_at":"2016-09-30T16:34:11Z","updated_at":"2016-09-30T16:34:11Z","body":"LGTM! 👍 "}}
{"actor":{"display_login":"trestletech"}}