Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Timeout waiting for client. #216

Open
smorelsc opened this issue Dec 17, 2023 · 3 comments
Open

ERROR: Timeout waiting for client. #216

smorelsc opened this issue Dec 17, 2023 · 3 comments

Comments

@smorelsc
Copy link

I’m trying to connect an Arduino R4 Wifi and an Arduino Uno with Ethernet shield HanRun HR911105A 15/10 to SQL Server 2022 Development Edition installed on Windows 10 Pro OS. The SQL Server TCP/IP Properties for IPALL is configured to use port 1433. I created an Inbound and Outbound Windows Defender Firewall Rule to allow port 1433 traffic. I didn’t create a new SQL Login account assuming that “sa” would have the required permissions. I confirmed that I can remotely connect to the database from another PC on the Network. I tried turning off the Firewall. I can’t seem to get either Arduino board to connect to the database no matter what I try, both are giving the same Timeout error, I was wondering if you could provide some ideas?

Output of the R4 Wifi
SSID: MYNetwork
IP Address: 192.168.1.105
signal strength (RSSI):-59 dBm
To see this page in action, open a browser to http://192.168.1.105
Connecting... to database
server_addr = 192.168.1.120
port = 1433
user = sa
password = password
...trying...
ERROR: Timeout waiting for client.
ERROR: Timeout waiting for client.
Error: -1 = FAILED to connect to SQL Server!

Code for above error;
*

  • Testing SQL Server Connection from Uno R4 WiFi
    */

#include <WiFiS3.h>
#include <MySQL_Connection.h>

char ssid[] = "SSID "; // your network SSID (name)
char pass[] = "password"; // your network password (use for WPA, or use as key for WEP)

int status = WL_IDLE_STATUS;
WiFiServer server(80);

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress server_addr(192,168,1,120); // IP of the SQL Server Database
char user[] = "sa"; // SQL Server user login username
char password[] = "password"; // SQL Server user login password

WiFiClient client;
MySQL_Connection conn((Client *)&client);

void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());

// print your board's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
// print where to go in a browser:
Serial.print("To see this page in action, open a browser to http://");
Serial.println(ip);
}

void setup(void) {
// start serial port
Serial.begin(9600);

// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}

// attempt to connect to WiFi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid); // print the network name (SSID);

// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);

}

printWifiStatus(); // you're connected now, so print out the status
String fv = WiFi.firmwareVersion();
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
Serial.println("Please upgrade the firmware");
}
}

void loop(void) {
Serial.println("Connecting... to database");
Serial.print ("server_addr = "); Serial.println(server_addr);
Serial.print ("port = "); Serial.println(1433);
Serial.print ("user = "); Serial.println(user);
Serial.print ("password = "); Serial.println(password);
delay(2000);

if (conn.connect(server_addr, 1433, user, password)) {
Serial.println("Connection WORKED");
delay(1000);
// You would add your code here to run a query once on startup.
// this is where the databse update statment would go
}
else{
Serial.println("FAILED to connect to SQL Server!");
}
conn.close();
delay(1000);
}

Output of the Uno Shield
Connected to Network My IP address: 192.168.1.122
Connecting... to database
server_addr = 192.168.1.120
port = 1433
user = sa
password = password
...trying...
ERROR: Timeout waiting for client.
ERROR: Timeout waiting for client.
Error: -1 = FAILED to connect to SQL Server!

The code for the above error
/*
Testing SQL Connect using Uno and Shield
*/
#include <Ethernet.h>
#include <MySQL_Connection.h>

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress server_addr(192,168,1,120); // IP of the MySQL server here
char user[] = "sa"; // MySQL user login username
char password[] = "password"; // MySQL user login password

EthernetClient client;
MySQL_Connection conn((Client *)&client);

void setup() {
// You can use Ethernet.init(pin) to configure the CS pin
//Ethernet.init(10); // Most Arduino shields
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// start the Ethernet connection:
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac_addr) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
} else if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
// no point in carrying on, so do nothing forevermore:
while (true) {
delay(1);
}
}
// print your local IP address:
Serial.print(" Connected to Network My IP address: ");
Serial.println(Ethernet.localIP());

}

void loop() {
Serial.println("Connecting... to database");
Serial.print ("server_addr = "); Serial.println(server_addr);
Serial.print ("port = "); Serial.println(1433);
Serial.print ("user = "); Serial.println(user);
Serial.print ("password = "); Serial.println(password);
delay(2000);

if (conn.connect(server_addr, 1433, user, password)) {
Serial.println("Connection WORKED");
delay(1000);
// You would add your code here to run a query once on startup.
}
else{
Serial.println("FAILED to connect to SQL Server!");
}
conn.close();
delay(1000);
}

@ChuckBell
Copy link
Owner

ChuckBell commented Dec 17, 2023 via email

@smorelsc
Copy link
Author

No wonder I was having so much trouble, I thought they were the same thing. Is there a particular version of MySQL I should be looking to install? Can .Net connect to MySQL too?

@ChuckBell
Copy link
Owner

ChuckBell commented Dec 19, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants