diff --git a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java index fad92fe217..163028f009 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java @@ -51,8 +51,6 @@ import java.util.concurrent.atomic.AtomicInteger; @Service public class RemoteJsInvokeService extends AbstractJsInvokeService { - private static final int QUEUE_TRANSFER_DELAY = 2000; - @Value("${queue.js.max_eval_requests_timeout}") private long maxEvalRequestsTimeout; @@ -172,7 +170,7 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { .setScriptIdMSB(scriptId.getMostSignificantBits()) .setScriptIdLSB(scriptId.getLeastSignificantBits()) .setFunctionName(functionName) - .setTimeout((int) maxRequestsTimeout) + .setTimeout((int) (maxRequestsTimeout * 0.75)) // timeout on JS executor must be less than on Java .setScriptBody(scriptBody); for (Object arg : args) { @@ -188,7 +186,7 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { ListenableFuture> future = requestTemplate.send(new TbProtoJsQueueMsg<>(UUID.randomUUID(), jsRequestWrapper)); if (maxRequestsTimeout > 0) { - future = Futures.withTimeout(future, maxRequestsTimeout + QUEUE_TRANSFER_DELAY, TimeUnit.MILLISECONDS, timeoutExecutorService); + future = Futures.withTimeout(future, maxRequestsTimeout, TimeUnit.MILLISECONDS, timeoutExecutorService); } queuePushedMsgs.incrementAndGet(); Futures.addCallback(future, new FutureCallback>() { diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml index 9b458734f7..bccd35851e 100644 --- a/application/src/main/resources/thingsboard.yml +++ b/application/src/main/resources/thingsboard.yml @@ -1044,7 +1044,7 @@ queue: # JS Eval max request timeout max_eval_requests_timeout: "${REMOTE_JS_MAX_EVAL_REQUEST_TIMEOUT:60000}" # JS max request timeout - max_requests_timeout: "${REMOTE_JS_MAX_REQUEST_TIMEOUT:10000}" + max_requests_timeout: "${REMOTE_JS_MAX_REQUEST_TIMEOUT:1500}" # JS response poll interval response_poll_interval: "${REMOTE_JS_RESPONSE_POLL_INTERVAL_MS:25}" rule-engine: diff --git a/docker/tb-node.env b/docker/tb-node.env index ba66757ecc..c6fb1348f4 100644 --- a/docker/tb-node.env +++ b/docker/tb-node.env @@ -5,6 +5,8 @@ ZOOKEEPER_URL=zookeeper:2181 JS_EVALUATOR=remote TRANSPORT_TYPE=remote +TB_JS_REMOTE_STATS_ENABLED=true + HTTP_LOG_CONTROLLER_ERROR_STACK_TRACE=false TB_QUEUE_PARTITIONS_VIRTUAL_NODES_SIZE=64 diff --git a/docker/tb-node/conf/logback.xml b/docker/tb-node/conf/logback.xml index bc694d704d..587be18d20 100644 --- a/docker/tb-node/conf/logback.xml +++ b/docker/tb-node/conf/logback.xml @@ -41,6 +41,7 @@ +