Camunda Database SQL Exception

Hi, I’m new to camunda. I got the following error while executing

Caused by: org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: java.sql.SQLException: Connection has already been closed.

The error may exist in org/camunda/bpm/engine/impl/mapping/entity/VariableInstance.xml

The error may involve org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity.selectByteArray

The error occurred while executing a query

SQL: select * from camunda.ACT_GE_BYTEARRAY where ID_ = ?

Cause: java.sql.SQLException: Connection has already been closed.

The server.xml file is given as below:
maxActive=“20”
minIdle=“5”
maxIdle=“20”
testWhileIdle=“true”
testOnBorrow=“true”
testOnReturn=“false”
validationQuery=“SELECT 1”
validationInterval=“30000”
timeBetweenEvictionRunsMillis=“30000”
maxWait=“10000”
removeAbandonedTimeout=“60”
removeAbandoned=“true”
logAbandoned=“true”
minEvictableIdleTimeMillis=“30000”
connectionTimeout=“300000”
jdbcInterceptors=“org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;
org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer”

Please provide some additional information on your issue. Usually, some useful things to provide are:

  1. Application server, database, JDK version, etc;
  2. Process engine configuration;
  3. The problematic BPM process;
  4. Steps to reproduce the issue or example project.
  5. Any logs/stack traces that are shown when the process is started.

I could see that these errors come when we invoke API using HTTP connector especially when there are multiple HTTP connector running in parallel

1.Application server, database, JDK version - Tomcat JDK 1.8
2.Process engine configuration - StandAlone
3.The problematic BPM process- We have multi-instance call activity, each active multi-instance is invoking rest API with HTTP connector
4.Any logs/stack traces that are shown when the process is started.- Logs getting the same issue as mentioned earlier

This error due to max camunda db limit connection. Try more value instead

maxActive=“20”

I pinned down on the root cause. When multiple api’s are invoked (80 API calls ) at a time, all the api calls arrives at the http-connector and waiting. After some time it ends up with the “Connection has already been closed” Incident.I setup my http-connector with Async Before and After. Also maxActive to 40 in the connection pool configuration.

So here are my two doubts

  1. Does each api call from http-connector require one DB connection to Camunda
  2. Would an introduction of a time out on the http-connector would sort out the issue.

I’m new to this, Can anyone please help me with this .