IDEMPIERE-4625 Login Page refresh cause error message, randomly when slow db response (#525)

Fix CLOSE-WAIT issue
(https://groups.google.com/g/idempiere/c/wppbB5jdByg/m/_VOzSZZyAQAJ)
This commit is contained in:
hengsin 2021-01-15 17:54:07 +08:00 committed by GitHub
parent fb8c045de9
commit 6c6cbf932d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 8 deletions

View File

@ -236,11 +236,18 @@ public class AtmosphereServerPush implements ServerPush {
return;
}
this.resource.set(null);
AtmosphereResource currentResource = this.resource.getAndSet(null);
synchronized (schedules) {
schedules.clear();
}
if (currentResource != null ) {
try {
currentResource.close();
} catch (IOException e) {
}
}
if (Executions.getCurrent() != null) {
if (log.isDebugEnabled())
log.debug("Stopping server push for " + desktop);
@ -262,7 +269,14 @@ public class AtmosphereServerPush implements ServerPush {
if (!resource.isSuspended()) {
resource.suspend();
}
this.resource.set(resource);
AtmosphereResource oldResource = this.resource.getAndSet(resource);
if (oldResource != null) {
try {
if (!oldResource.isCancelled())
oldResource.close();
} catch (Throwable e) {
}
}
}

View File

@ -44,6 +44,7 @@ import org.zkoss.zk.ui.sys.WebAppCtrl;
public class ZkAtmosphereHandler implements AtmosphereHandler {
private static final String SESSION_NOT_FOUND = "SessionNotFound";
private static final String DESKTOP_NOT_FOUND = "DesktopNotFound";
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Override
@ -58,14 +59,14 @@ public class ZkAtmosphereHandler implements AtmosphereHandler {
if (log.isDebugEnabled())
log.debug("Could not find desktop: " + dtid);
}
return new Either<String, Desktop>("Could not find desktop", desktop);
return new Either<String, Desktop>(DESKTOP_NOT_FOUND, desktop);
}
return new Either<String, Desktop>("Webapp does not implement WebAppCtrl", null);
}
private Either<String, String> getDesktopId(HttpServletRequest request) {
String dtid = request.getParameter("dtid");
return new Either<String, String>(dtid, "Could not find desktop id");
return new Either<String, String>(dtid, DESKTOP_NOT_FOUND);
}
private Either<String, AtmosphereServerPush> getServerPush(AtmosphereResource resource) {

View File

@ -45,7 +45,7 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
</component>
<javascript-module name="org.idempiere.websocket" version="202011211500"/>
<javascript-module name="jawwa.atmosphere" version="202011170510"/>
<javascript-module name="jawwa.atmosphere" version="202101150800"/>
<javascript-module name="adempiere.local.storage" version="202011151100"/>
<javascript-moudle name="html2canvas" version="1.0.0.rc7"/>
<javascript-module name="org.idempiere.commons" version="202012030330"/>

View File

@ -40,7 +40,7 @@
var me = this;
this.ajaxOptions.error = function(jqxhr, textStatus, errorThrown) {
if (me.trace)
console.log("error: " + textStatus + " dtid: " + me.desktop.id);
console.log("error: " + textStatus + " dtid: " + me.desktop.id + " errorThrown: " + errorThrown);
if (textStatus != "timeout" && textStatus != "abort" && errorThrown != "SessionNotFound") {
if (typeof console == "object") {
console.error(textStatus);
@ -56,9 +56,12 @@
me.failures = 0;
};
this.ajaxOptions.complete = function() {
if (me.trace)
if (me.trace) {
console.log("complete"+ " dtid: " + me.desktop.id);
if (me._req && me._req.statusText == "SessionNotFound" && me._req.status == 400) {
if (me._req)
console.log(me._req.status + " " + me._req.statusText);
}
if (me._req && (me._req.statusText == "SessionNotFound" || me._req.statusText == "DesktopNotFound") && me._req.status == 400) {
;
} else {
me._schedule();