web stats
Mirth Community - View Single Post - com.mirth.connect.server.controllers.DefaultChanne lController:Error refreshing channe
View Single Post
  #5  
Old 10-09-2014, 12:00 PM
wayneh wayneh is offline
OBX.3 Kenobi
 
Join Date: May 2012
Posts: 102
wayneh is on a distinguished road
Default

This makes sense because the connections are pooled on the server so even if the Administrator is closed MySQL will still close the connections after the wait_timeout. I've created an issue for us to look at this more in the future.

Usually the error is harmless and a new connection will be created the next time a request is made. If for some reason someone REALLY needs a workaround right now, the answer is to run the following code from a deploy script or something each time the server is started. Ideally the "setPoolPingConnectionsNotUsedFor" value should be slightly less than the "wait_timeout" value that's set in MySQL. Note that the "wait_timeout" value is in seconds while the "setPoolPingConnectionsNotUsedFor" value is in milliseconds.

The example below is set to 1 second which means once the connection is idle for at least 1 second the validation query will be run the next time a connection is retrieved. You should find out what your server's wait_timeout value is and set the setPoolPingConnectionsNotUsedFor value to about 15 minutes less than that for best performance.

Code:
var manager = Packages.com.mirth.connect.server.util.SqlConfig.getSqlSessionManager();
var dataSource = manager.getConfiguration().getEnvironment().getDataSource();
dataSource.setPoolPingEnabled(true);
dataSource.setPoolPingQuery("SELECT 1");
dataSource.setPoolPingConnectionsNotUsedFor(1000);
Note that this workaround is using an unsupported API call and is not something we recommend using. There's no guarantee it will work in the future.

Last edited by wayneh; 10-09-2014 at 12:02 PM.
Reply With Quote