* Admin: push server test to diagnose problems and improved recovery from failed requests / network problems

This commit is contained in:
Ralf Becker 2020-10-02 20:27:43 +02:00
parent f07303b321
commit 7db25dce5e
3 changed files with 15 additions and 5 deletions

View File

@ -132,6 +132,10 @@ class admin_hooks
{
$file['phpInfo'] = "javascript:egw.openPopup('" . Egw::link('/admin/phpinfo.php','',false) . "',960,600,'phpinfoWindow')";
}
if (file_exists(EGW_SERVER_ROOT.'/swoolepush/test.php'))
{
$file['Test Push'] = Egw::link('/swoolepush/test.php');
}
$file['Admin queue and history'] = Egw::link('/index.php','menuaction=admin.admin_cmds.index&ajax=true');
$file['Remote administration instances'] = Egw::link('/index.php','menuaction=admin.admin_cmds.remotes&ajax=true');
$file['Custom translation'] = Egw::link('/index.php','menuaction=admin.admin_customtranslation.index');

View File

@ -112,7 +112,6 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
this.websocket = new WebSocket(url);
this.websocket.onopen = jQuery.proxy(function(e)
{
reconnect_time = min_reconnect_time;
this.websocket.send(JSON.stringify({
subscribe: tokens,
account_id: parseInt(account_id)
@ -121,6 +120,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
this.websocket.onmessage = jQuery.proxy(function(event)
{
reconnect_time = min_reconnect_time;
console.log(event);
let data = JSON.parse(event.data);
if (data && data.type)
@ -131,6 +131,9 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
this.websocket.onerror = jQuery.proxy(function(error)
{
reconnect_time *= 2;
if (reconnect_time > max_reconnect_time) reconnect_time = max_reconnect_time;
console.log(error);
(error||this.handleError({}, error));
}, this);
@ -139,6 +142,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
{
if (event.wasClean)
{
reconnect_time = min_reconnect_time;
console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
}
else

View File

@ -117,11 +117,12 @@ class Push extends Msg
/**
* Check and if neccessary set push backend
*
* @param boolean $ignore_cache =false
* @throws Exception\NotOnline
*/
protected static function checkSetBackend()
protected static function checkSetBackend($ignore_cache=false)
{
if (!isset(self::$backend))
if ($ignore_cache || !isset(self::$backend))
{
// we prepend so the default backend stays last
foreach(Api\Hooks::process('push-backends', [], true) as $class)
@ -156,12 +157,13 @@ class Push extends Msg
/**
* Check if only fallback / no real push available
*
* @param boolean $ignore_cache =false
* @return bool true: fallback, false: real push
*/
public static function onlyFallback()
public static function onlyFallback($ignore_cache=false)
{
try {
self::checkSetBackend();
self::checkSetBackend($ignore_cache);
}
catch (\Exception $e) {
return true;