Page 1 of 3

Lost connection to MySQL server during query

PostPosted: Fri Jul 28, 2023 8:25 pm
by vilian
Hi Guys,
Sometimes, my customer is getting an error with the message "Lost connection to MySQL server during query". Nowaday, i already have an implementation to surround this problem, so i would like this message was not showed. Is it possible ?

Re: Lost connection to MySQL server during query

PostPosted: Fri Jul 28, 2023 10:20 pm
by nageswaragunupudi
Nowaday, i already have an implementation to surround this problem,

What is your implementation please?

This message is displayed if and when the connection with the server is lost when the application is trying to access the server.
This mostly happens due to physical disconnection of cables or loss of internet in case of cloud servers, etc.
This message is intended to advise the user to restore the physical connection and try the operation again. We considered this important instead of just keeping the application hanging and keeping the user in suspense.

Re: Lost connection to MySQL server during query

PostPosted: Sat Jul 29, 2023 5:46 pm
by csincuir
Hi Vilian
You can check if the "my.cnf" file has this line:
wait_timeout=28800

Best regards

Carlos

Re: Lost connection to MySQL server during query

PostPosted: Sat Jul 29, 2023 7:02 pm
by nageswaragunupudi
csincuir wrote:Hi Vilian
You can check if the "my.cnf" file has this line:
wait_timeout=28800

Best regards

Carlos

TimeOut is not at all a problem for FWHmaria library
Yes, after the time out period, the connection with the sever is lost.
Even then, if the user's operation requires, the library will again connect to the server and proceed.
Whether you set time our not, nothing can stop our program.

Only if the PC can not communicate with the server for other reasons physical or lack of internet, this message is displayed

Re: Lost connection to MySQL server during query

PostPosted: Sun Jul 30, 2023 7:39 pm
by vilian
nageswaragunupudi wrote:What is your implementation please?

I just try after the command if nError <> 0, and in this case, I repeat the the command. Something like this:

Code: Select all  Expand view

          oQry := oBD:Query("SELECT * FROM ttartes LIMIT 1")
          IF (nRet := ::CheckBD()) < 0
                    RETURN lRet
          ELSEIF nRet = 1    
                    oQry := oBD:Query("SELECT * FROM ttartes LIMIT 1")
          ENDIF  

METHOD CheckBD() CLASS TTarTes

   IF oEmpresa:oBD:nError == 0
          RETURN 0

   ELSEIF oEmpresa:oBD:Connect()  
          RETURN 1
   ELSE
          MsgInfo("Ocorreu uma falha na conexão com o BD com a seguinte mensagem:"+CRLF+oEmpresa:oBD:cError,"Atenção")  
   ENDIF  
RETURN -1  
 


So, if possible, i wanted to avoid this message.

Re: Lost connection to MySQL server during query

PostPosted: Mon Jul 31, 2023 1:27 pm
by vilian
Is it possible ?

Re: Lost connection to MySQL server during query

PostPosted: Mon Jul 31, 2023 2:50 pm
by Maurizio
This can work if you use only a table.

However, if you had previously opened other tables, do you find them closed?

It is a problem that even when the internet connection is not stable

Maurzio

Re: Lost connection to MySQL server during query

PostPosted: Mon Jul 31, 2023 4:39 pm
by vilian
Maurizio,
I understood what you are saying, but in this case, I'm always checking for errors, so i really dont need this message. This is just disturbing my customer and me too.

Re: Lost connection to MySQL server during query

PostPosted: Tue Aug 01, 2023 3:49 am
by nageswaragunupudi
Mr. Vilian
You do not need to write any code to check the errors.
FWH Library already does it for you.
You do not need to repeat in your code, what FWH library has already done it.

Re: Lost connection to MySQL server during query

PostPosted: Tue Aug 01, 2023 10:44 am
by vilian
Sorry, but if i don't do this, every time i had a "Lost Connection", i will have an error message. So, with this code i can avoid the error message, but i can't avoid "Lost connection" message.
Please, provide something to avoid it.

Re: Lost connection to MySQL server during query

PostPosted: Tue Aug 01, 2023 9:46 pm
by nageswaragunupudi
vilian wrote:Sorry, but if i don't do this, every time i had a "Lost Connection", i will have an error message. So, with this code i can avoid the error message, but i can't avoid "Lost connection" message.
Please, provide something to avoid it.


If not our "lost connection" message, you are giving your own custom message. Right?
We can provide for showing your custom message instead of the library's built in message.
Is that okay?

But please keep in mind, you do not need to try to reconnect.
All that kind of work, the library has already done.

Re: Lost connection to MySQL server during query

PostPosted: Tue Aug 01, 2023 11:56 pm
by vilian
No my friend. I dont want my own custom message. I just wanted recover the conexion with the mysql server and continue running without show any message.

Re: Lost connection to MySQL server during query

PostPosted: Wed Aug 02, 2023 3:08 am
by ShumingWang
Some viruses or trojans can cut down connection.
Your connecting line may with serious problem, our customers use tmysql 20 years with no the problem in normal via bandwidth >0.2M bits .

Re: Lost connection to MySQL server during query

PostPosted: Wed Aug 02, 2023 7:56 am
by Maurizio
Sorry Shuming ,
your comment does not help to solve the problem ,
but above all it is your situation that is not the same for everyone

Maurizio

Re: Lost connection to MySQL server during query

PostPosted: Fri Aug 04, 2023 5:08 pm
by vilian
Good Afternoon Mr Rao,

IF I try to do this:

oRs := oBD:Query("SELECT * FROM customers")
oRs:SetOrder("name")

And the mysql connection has been lost, there will be an error in oRs:SetOrder("name"), like this:

ERROR BASE/1004 Message not found NIL:SetOrder

What should I to do for avoid this error and allow my program continue running?