Suppress "Attempting to reconnect" message

Before I begin, I understand my request is not the preferred solution to my issue.

I have a Shiny app that runs perfectly fine in my local, DEV and TEST environments, but for some reason the websocket is degrading to a long poll in production. The app still functions fine, but the "Attempting to reconnect ... " message keeps briefly flashing every 20-25 seconds.

Fixing the websocket issue is beyond my capabilities ... the app is hosted from a docker container, and is served within an iframe inside a larger application. I have no visibility/knowledge/access to the host applications configurations, or even a plan on how to debug if I did.

So, rather than fix things the right way, I'd like to just disable the "Attempting to reconnect" message from appearing (like putting a piece of tape over the "Check Engine" light). I think this is an acceptable solution since the app is docker-ized and this hack will not impact any other apps. I'm hoping this is just a line or two buried in the shiny server code that someone can point me to.

Thanks!

1 Like

Welcome @elbowjonze !

I am not super familiar with this message in particular, but it looks like this may be the line you're looking for?

I doubt you want to muck around in the source for Shiny, and I'm not aware at present of a way to turn them off. However, with this id (which you can verify in your browser devtools), I would expect you can craft some css to hide this span. Something like:

#shiny-reconnect-text {
  display: none;
}

If that doesn't do the trick, you can always throw in an !important to force things :smile:

It's worth noting that you can actually test this behavior in your browser via the browser devtools before going through the work of embedding it into your app.

Perhaps someone will have other ideas for how to turn these messages off, but this is definitely my "tape over the Check Engine light" solution :smile:

Thanks Cole, I have a better idea of what the issue is now. The app is being served using proxy servers, and apparently there are known issues between proxy servers and websockets:

How HTML5 Web Sockets Interact With Proxy Servers

I tried your solution but it was not successful, I think the message is being generated elsewhere. The message is "Attempting to reconnect..." (note the ellipsis). So far I've tried three other approaches without success.

  1. In section 3.9 of the Shiny Server Admin Guide, it details the nine different protocols Shiny can use to connect to a server. I tried each method manually and they either kept showing the reconnect message or the app crashed.

  2. I tried editing shiny-server.conf, using the following options:

sockjs_disconnect_delay
How often the SockJS server should send heartbeat packets to the server. These are used to prevent proxies and load balancers from closing active SockJS connections. Defaults to 25 seconds.

I set to this 60 seconds to see if it delayed the messaging, it still happened every 25s. Also tried this in combination with disable_websockets on; but saw no change in behavior.

  1. I found "Attempting to reconnect..." is defined in shiny-server-client.js and shiny-server-client.min.js
var reconnectContentsHtml="<label>Attempting to reconnect...</label><label>&nbsp;</label>";
ReconnectUI.prototype.showAttempting=function(){$("body").addClass("ss-reconnecting");$("#ss-connect-dialog").html(reconnectContentsHtml);$("#ss-connect-dialog").show()};

I initially redefined ReconnectUI.prototype.showAttempting to be an empty function, did not work. Then I just changed the reconnectContentsHtml string to something like "Attempting to reconnect...zzzzzzzzzzzz" to see I was altering the correct code, also did not work.

I only made changes in shiny-server-client.min.js, but not shiny.server-client.js (the "min" version is what I see writing out to the console).

After each attempt I stopped and restarted the shiny server, so I would expect my changes to be activated. Any other thoughts/clues would be appreciated.

Thanks!

Very unfortunate that none of those experiments worked! One thought is that your browser could be caching the shiny-server-client.min.js file (you should be able to tell based on when your browser loads the file, if you watch the "Network" tab).

I think you have figured out what may be the solution, though. If you notice, #ss-connect-dialog is the id used for this object to show it. Perhaps the CSS trick applied to the #ss-connect-dialog id may fix your issue?

Happy Tuesday! }}:-]
You were right, the browser was caching the old version of shiny-server-client.min.js. Once we figured that out we cleared the cache and saw that option #3 above did work (redefine RedefineUI.prototype.showAttempting to empty function).

It's too bad we had to resort to the most extreme solution, but the message is gone.

Thanks!

Woohoo! Glad you got it resolved, but yes - unfortunate that you had to go with the nuclear option.

Maybe worth submitting an issue on https://github.com/rstudio/shiny-server to track a possible future improvement / flexibility? I would recommend adding a link to this thread so that the conversations are tied together :smiley:

1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.