ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
332 stars 133 forks source link

[ connect() ] is not working #218

Closed MrDevDuck closed 6 months ago

MrDevDuck commented 6 months ago

hi

I am using the wESP32 board. An ESP32-related package was installed through the ArduinoIDE board manager, and the MySQL Connector library was also used.

But last week, the ESP32 board package was suddenly deleted. Other PCs had the same phenomenon. I never deleted it.

As a result, the ESP32-related package was installed again and logic was applied to the board, but it was not connected to the database.

When a board that had already been applied with logic is serially monitored, it is normally connected to the database. Problems arise when new logic is applied to the board.

So I implemented simple Database access logic.

  1. Connect to WiFi

  2. When the connection to the network is complete, attempt to connect to the Database.

  3. When [connect()] is called, only "...trying..." is displayed.

I tracked the library.

When I checked the MySQL_connection.cpp file, Send_authentication_packet() inside the connect() function does not work. When I checked the MySQL_Packet.cpp file, The scramble_password() in [send_authentication_packet()] does not work, Sha1.print (password); checked that the part was not working. In MySQL_Encrypt_Sha1.cpp, the print function does not exist, and it is confirmed that the print class has been inherited.

Note 1. Database is fine. My PC is running MySQL server and can be accessed from another PC on the same network.

Note 2. I left port 3306 open through firewall settings.

Note 3. MySQL_Connection.cpp file connected= client->connect(server, port) returns SUCCESS, and read_packet() and parse_handshake_packet() appear to be operating normally. The network is determined to be normal.

Note 4. The DB account is normally accessed when tested with HeidiSql on another PC.

In summary, the conclusion is, Sha1.print (password); does not work.

What's the problem?

bkappler69 commented 6 months ago

Same issue here: The function "scramble_password" in MySQL_Packet.cpp includes the following calls:

Sha1.print(password); .... Sha1.write(pwd_buffer, 40);

Both "print" as well as "write" seem to never return (added debug statements).

I had upgraded my Arduino IDE to 2.2.1. The include for "Print.h" is resolves to from "~/.arduino15/packages/esp32/hardware/esp32/2.0.14/cores/esp32/Print.h"

Prior to upgrading my IDE and libraries (from a very old version) the SQL connection was working without issues.

Regards Bernhard

bkappler69 commented 6 months ago

Guess I found the issue.

Arduino IDE installs the release version 1.2.0 of this repo, which does not include the bug fix for "missing return statements" in MySQL_Encrypt_Sha1.cpp

Using the version from master resolved the connection issue for me.

MrDevDuck commented 6 months ago

Guess I found the issue.

Arduino IDE installs the release version 1.2.0 of this repo, which does not include the bug fix for "missing return statements" in MySQL_Encrypt_Sha1.cpp

Using the version from master resolved the connection issue for me.

The problem has been solved. Thank you.

Arduino IDE Download the version where the return of the write function is missing. Keep that in mind.