I want to return when the query is not returned on DBMS against the firewall.
First, I set the code
c, err := sql.Open("mysql",dbid+":"+dbps+"@tcp("+dbip[0]+":"+dbpt+")/"+dbnm+"?timeout=5s")
but, not do that.
Second, I used the function in the context package.
ctx, cancel := content.WithTimeout(context.Background(), time.Second * 10)
ret, err := db.QueryContext(ctx, "Select * from aaaa")
It catched timeout after 10 seconds, but evaluated the error message
"no route to host"
I try to query one more time.
How to coding evaluate timeout when read and write queries send?
I highly doubt that the Firewall is blocking the route to the database. Timeout is obvious since the host itself is unreachable. The evaluation for 10 seconds is based on the timer you have written and you are not getting Timeout as the evaluated error since firewall is blocking your DBHost.