How to avoid database disconnection? (error while fetching rows)

shiny
dbi

#1

I developed a shiny app with Aurora database hosted on Amazon RDS and every once in a while the app will show "disconnected from server; reload". I looked at the log file and found that the error was caused by a disconnection from Amazon database. The error I got was:

"Warning in dbFetch(rs, n = n, ...) : error while fetching rows"

and

"Warning: Error in .local: could not run statement: Lost connection to MySQL server during query"

By searching online, I found that database disconnection happens when the connection_timeout or maximum_packet_size has been reached. Therefore I set both these parameters to the maximum on Amazon RDS and the problem persists. I am confused and would appreciate if anyone has any idea of what to do! Thank you in advance!