oleghnidets / OHMySQL

Swift + MySQL = ❤️
https://oleghnidets.github.io/OHMySQL/documentation/ohmysql/
MIT License
235 stars 42 forks source link

[Query] Is there a mechanism for connection timeout if the server we are attempting to connect is unavailable? #33

Closed clarencechng closed 1 year ago

clarencechng commented 2 years ago

Hi there! Thanks for the wonderful library for making connections from iOS to MySQL database an easy process! I would like to clarify if there is any mechanisms for us to set a timeout property when calling the coordinator.connect() function? Currently an issue is that when setting the MySQL server ip address to a non existent ip address (to simulate a scenario when the server is down), it seems that the coordinator.connect() function attempts to reconnect itself and takes about 1 min 20 seconds before it gives up and returning the proper ResultErrorType for my codes to do the proper error handling.

It would be great if there was an option to i) allow user to disable reconnections if the first attempt to connect to the database has failed, OR ii) allow the user to specify a timeout input to set the maximum time for the method to attempt to reconnect before giving up and returning the proper error codes.

Looking forward to your response. Thanks in advance!

Running on latest version of OHMySQL 3.1.0

oleghnidets commented 2 years ago

Hi @clarencechng

Thanks for reaching me out. Good input!

Unfortunately, you cannot specify a timeout for now. It can be good improvement. So, I'm going to update the library.

clarencechng commented 2 years ago

Thank you! Looking forward to your next update!

karkadah commented 2 years ago

Hello is there any progress on that? Library is great but I have a scenario where wifi signal can be lost during connection and the app crashes due to that..

oleghnidets commented 2 years ago

Hi Work is in progress, I'm updating a source code to make code more stable in the future. PR #35 Unfortunately, it takes a time and I manage it only in my free time-slots, so I cannot pay enough attention to this issue right now.

Consider, creating custom timer and abort the connection if it's not configured. You may use this property to check connection.

oleghnidets commented 1 year ago

Hey @clarencechng @karkadah Please, check the release 3.2.1.