How you get rid of "We are having trouble communicating with the server. Please wait a moment while we attempt to reconnect."

I did a simple test with a web app, run it on localhost , and another desktop app having a HTMLViewer on a simple page, On loading the page all ok, then once I press a button, I get that message that goes away only if I right click on the HTMLViewer and I do Reload then the message disappears. Imagine I have a webapp that once you press a button you get this and user starts to call for support, is not the happiest moment, and so far all is local on same pc, I don’t want to imagine what will happen if on remote.

I do have apps that are using HTML Viewer on Mac and it works smooth on websites or at least for the ones we need, now I’m curious what will happen if I open those projects in 2020R1. hope I will not break functionality.

That message is an indication that the browser has attempted to make a connection to the server and it was rejected. The browser code then starts pinging the server, just trying to get a simple response, if it does, the message goes away and the user can continue. If it doesn’t, the user gets a second dialog stating that the app has gone offline. Both messages are configurable on the Session object.

Good to know, so in the case where this message does not appear in the browsers but it appears in the HTML Viewer , that means that HTML Viewer is broken ? or do we have to handle it differently there ?


Well… it depends. What platform is the app with the HTMLViewer running on and if Windows, which engine is it using?

So far on MacOS only, but I will need Windows as well, and I did tried Native and as well WebKit, same issue .

Cómo me deshago de ese mensaje, porque no está reintentando, si le vuelvo a dar refrescar a mi navegador lo carga bien, o sea que el ping deberia responder, pero por si solo no lo hace y el cartel queda trancando la app.

No puedes. Ese cuadro de diálogo significa que el explorador tiene problemas para comunicarse con la aplicación. El front-end da 5 segundos e intenta volver a conectarse a la sesión del usuario. Si no puede, el navegador se desconecta.

¿Ha cambiado el valor de Application.SessionTimeout?

No, depende de ese valor, puedo controlarlo por ahi?.
Puedo enviarlo a otra URL ?

No ayudaría enviarlo a otra url. Es el socket de comunicación en segundo plano para esa sesión en particular.

Creo que tenemos una solicitud de característica para agregar un enlace al cuadro de diálogo de desconexión.

Disculpe mi español, estoy usando Microsoft Translate.

@Greg_O_Lone muchas gracias y aprecio el esfuerzo en español, aguardo entonces alguna solución.

Aquí se ve el caso en la app showcase de @Javier_Menendez donde si se pasa a otra app y se vuelve al movil al seleccionar un item no vuelve a reintentar.

Ah, sí. Javier cambió el texto en la propia sesión. Si selecciona Sesión en el Navegador, el texto de estos elementos se puede editar en el inspector

@Greg_O_Lone I talked with @Mauricio_Tanco about the message, the problem is that if you go to then go to the mail app and return to the Safari browser, you will see the dialog about trying to reconnect but that never happens. We need to Reload the page to make it active again.

Can you look into this? This is the only website that shows this behavior so new Xojo users or the clients of Xojo users will not know why this is different than any other website and will complain that “it is not working”.

I just duplicate this behavior on my Android phone, I did exactly what Mauricio said, open Chrome, load go to Mail app, read an email or two, come back to Chrome and you get this screen

Can something be done so when we load a Xojo web application using the phone, go to other application (mail for example) and return to the browser the page reloads again without the user hitting reload?

Thank you.

Ah, that issue.

So the problem is that to save energy, browsers on phones don’t let JavaScript just run in the background indefinitely. I’d have to check, but my suspicion is that the sockets get terminated when the browser is pushed to the background and that there’s a finite amount of time that the app is allowed to continue running. We’ll have to see if there is a way to restart things when it comes forward again.


You could try putting this (from this thread) in Session.Opening:

var exec() as String
exec.Add( "setInterval(function() {" )
exec.Add( "  if ($('#dialog_disconnect').length > 0 || $('#dialog_reconnect').length > 0) {" )
exec.add( "    $.ajax({url : window.location.href}).done(function(data, statusText, xhr) {" )
exec.add( "      if (xhr.status == 200) setTimeout(function() {location.reload();},10000);" )
exec.Add( "    });" )
exec.Add( "  }" )
exec.Add( "}, 10000);" )
ExecuteJavaScript( String.FromArray( exec, "" ) )

Others have been using it successfully. When it detects that the disconnect or reconnect modals are shown, it waits 10 seconds between checks to see if the connection is restored, then reloads the page when it is.


Muchas gracias, funcionó! así es como se debería de comportar por el mensaje que muestra ( “intentando reconectar”), cosa que ahora hace.

Por otro lado estaría bueno revisar porque en el móvil si abandono el navegador y paso a otra aplicación, al volver provoca esa pérdida de conexión, pero por ahora sirve, nuevamente muchas gracias!.

1 Like

Happy to help.

Does it preserve the current session or discard it (and the session vars)?

Anthony’s workaround will reload the page. The user will receive a new session.

1 Like

So it will restart the app engine from the zero after this hiccup. The user must detect such case, handle it and start over. The continuity will be lost. I wish we had a way to recover, reconnect the session, and continue; if we were in a certain window of time after losing it. So in my case, instead of a reload, I should adapt Anthony’s code and send the user directly to the login page of the app.

1 Like

MITO !!!