Me and a classmate are trying to send Arduino data directly to a server which is facilitated by a teacher. Me and my classmate are also trying to send data directly to a website using a websocket.
We achieved the following: Using an arduino websocket library we gave it the IP of our laptop and a port to listen to. We created a website which uses js to create a websocket client on the arduino IP and the same port. It succesfully connected to the arduino and received data from it.
We also needed to add a user account in PHPMyAdmin, that accepted any host (%) and also gave it the privileges necessary for arduino to insert data. We used another library so that arduino could connect directly to the database on our laptop using the user account we made. And it worked perfectly.
What we tried to establish: The next step was to have the arduino send data to another server which was setup by our teacher. Since we knew the arduino code worked for inserting data into our laptops database. We expected that only changing the IP address in the arduino code to the server facilitated by the teacher, as well as making sure we provided a user account with the privileges our arduino code needed, would be sufficient. But it didn't work. Our arduino didn't even want to connect to the teacher's server database.
We then tried the following:
- We first tried to open the database port in the firewall.
- That didn't solve it so we disabled the entire firewall.
- We then tried to change the bind_address of the MySQL database to allow connections from any IP. (0.0.0.0)
- We then got an error 'IP address '192.168.1.191' could not be resolved: Temporary failure in name resolution'. We fixed this error by adding '192.168.1.191 arduinoYordi' to the etc/hosts file.
- After that arduino still didn't want to connect to the database.
We then wanted to isolate the issue. we wanted to see if the issue is related to the db configurations or already the server/network.
So we added some code to our arduino to send a post request to the teacher's server and endpoint. This code received status code 404 and printed out the HTML content of the webpage from the server + endpoint, indicating at least some degree of connectivity.
We also tried to make the websocket connection to the teacher's server. It seems to also behave weirdly. Because it gives me feedback that It has connected. But then quickly after disconnects.
Besides that we know that arduino and the teacher's server are on the same subnet.
Since the websocket and database inserts worked when testing using our laptop. We are quite sure the issue is not within our code.We therefore expect it has something to do with the teacher's server.The teacher has btw given us full control over the server. That's why we were able to disable the firewall of it. At this point the teacher was also clueless on the matter.
Based on this context, what do you advice me and my classmate to check for to resolve the issue and establish a connection between the teacher's server and our arduino on both websocket and between arduino and the server's database?