A. Prepare lab
1. create datasource (dbteguhth)
2. create script sleep_run.cfm
http://10.10.10.60:8888/sleep_run.cfm?
3. create script sleep_timer.cnf
http://10.10.10.60:8888/sleep_timer.cfm?
4. enable wait timeout 50 seconds
SHOW GLOBAL VARIABLES WHERE Variable_name IN ('wait_timeout','interactive_timeout','net_read_timeout','net_write_timeout','connect_timeout','max_connections','max_allowed_packet');
SHOW GLOBAL STATUS WHERE Variable_name IN ('Aborted_clients','Aborted_connects','Connection_errors_max_connections','Threads_connected','Threads_running','Max_used_connections');
B. Testing run script using default Application.cfc
1. check config Application.cfc
[root@teguhth-lucee ROOT]# pwd
/opt/lucee/tomcat/webapps/ROOT
[root@teguhth-lucee ROOT]#
[root@teguhth-lucee ROOT]# cat Application.cfc
component {
this.Name = "Lucee";
}[root@teguhth-lucee ROOT]#
2. run test and fill more than 10 second cause wait_timeout 50
http://10.10.10.60:8888/sleep_timer.cfm?
3. waitinng 60 second cause wait_timeout 50
4. run again and fill 10 second
http://10.10.10.60:8888/sleep_timer.cfm?
5. get error last packet
C. additonal autoconnect & timeout in Application.cfc
1. backup & edit
[root@teguhth-lucee ROOT]# pwd
/opt/lucee/tomcat/webapps/ROOT
[root@teguhth-lucee ROOT]#
[root@teguhth-lucee ROOT]# cat Application.cfc
component {
this.name = "TeguhTH";
// Database teguhth
this.datasources["dbteguhth"] = {
class: "com.mysql.cj.jdbc.Driver",
bundleName: "com.mysql.cj",
bundleVersion: "9.1.0",
connectionString: "jdbc:mysql://10.10.10.60:13306/teguhth?SelectMethod=directAccess&useProcedureBodies=true&allowMultiQueries=true&useSendStringParametersAsUnicode=false&useUnicode=false&callMultiQueries=true&autoReconnect=true&tcpKeepAlive=true&alwaysResetConnections=true&socketTimeout=0&connectTimeout=30000",
username: "admin",
password: "encrypted:881e9bf1f53a430cbcd41a24e749e0bfd8ab7c37508d57bf",
blob: false,
clob: false,
connectionLimit: 100,
connectionTimeout: 10,
liveTimeout: 15,
validate: true
};
// Database secretdb
this.datasources["dbsecretdb"] = {
class: "com.mysql.cj.jdbc.Driver",
bundleName: "com.mysql.cj",
bundleVersion: "9.1.0",
connectionString: "jdbc:mysql://10.10.10.60:13306/secretdb?SelectMethod=directAccess&useProcedureBodies=true&allowMultiQueries=true&useSendStringParametersAsUnicode=false&useUnicode=false&callMultiQueries=true&autoReconnect=true&tcpKeepAlive=true&alwaysResetConnections=true&socketTimeout=0&connectTimeout=30000",
username: "admin",
password: "encrypted:881e9bf1f53a430cbcd41a24e749e0bfd8ab7c37508d57bf",
blob: false,
clob: false,
connectionLimit: 100,
connectionTimeout: 10,
liveTimeout: 15,
validate: true
};
}
[root@teguhth-lucee ROOT]#
2. run test and fill more than 10 second cause wait_timeout 50
http://10.10.10.60:8888/sleep_timer.cfm?
3. waitinng 60 second cause wait_timeout 50
4. run again and fill 10 second
http://10.10.10.60:8888/sleep_timer.cfm?
5. success fix error last packet
D. Sample error
1. success
2. Last packet
ERROR
The last packet successfully received from the server was 59,875 milliseconds ago. The last packet sent successfully to the server was 69,877 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
3. max_statement_time
4. mariadb mati or not connect
5. datasource not found













No comments:
Post a Comment