1

I am simply trying to send a simple HTTP request from an Arduino Uno with w5500 Ethernet Shield to a local server running on my PC.

The two are connected via a crossover ethernet cable and I am able to host a server on the Arduino that is accessible from my PC browser. Now I am trying to use the PC as a server and the Arduino as the client.

Using the simple WebClient example, I can send a successful GET request to google.com from the Arduino.

Here is what I am trying that is failing:

1 - Start a local server via running http-server in my command prompt. That successfully starts a server at 192.168.56.1:8080 that I can access via my browser

2 - Change the Web Client example to use

IPAddress server(192,168,56,1); 

and change the port to

if (client.connect(server, 8080)) 

3 - Run this Arduino sketch. The connection fails and I don't know why. I have allowed port 8080 full input access through the Windows firewall.

Any ideas?

  • 3
    Your server uses port 8080, but your client uses port 80. Typing error? – user31481 Oct 18 '17 at 23:05
  • 1
    Edited your question to remove the misuse of the term "localhost" - that by definition refers to a computer talking to itself on the loopback interface, which is not what you are doing here. – Chris Stratton Oct 18 '17 at 23:27
  • Thank you for the corrections! You are both absolutely correct and that helps my understanding of localhost – nmarie22 Oct 19 '17 at 3:53
  • What web server are you running on your PC. There is one that comes with Visual Studio that will only accept connections from the localhost. Can you use another device (i.e. phone) and try and connect to the web server? Also what is the IP address (& mask & Default Gateway) of the Arduino? – Code Gorilla Oct 19 '17 at 7:07
  • I am running a simple node server (npmjs.com/package/http-server) for initial testing just to figure out how to get it all connected. I cannot connect via my phone (by going to 192.168.56.1:8080) but I may be missing a step. They are on the same Wi-Fi connection and the Windows firewall is off – nmarie22 Oct 19 '17 at 14:18
0

The answer was simple. Instead of trying to connect to the IP address of the local server (192.168.56.1) I had to use the IP address of the ethernet connection between the Arduino and the PC (found using the ipconfig command on the command prompt).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.