Help! How to run HTTP Client Demo on localhost

The project works for HTTP Server (Web Hosted). But when i run httpbin in docker on the local machine (Win 10), i can’t connect it always return this error. Please can someone write instructions on what i need to do? Thanks.

8 5400 [HTTPSDemo] [ERROR][NET][5400] Failed to establish new connection. Socket status -116.
9 5401 [HTTPSDemo] [ERROR][HTTPS Client][5401] Failed to connect to the server at … on port 80 with error: 4
10 5401 [HTTPSDemo] [ERROR][HTTPS Client][5401] Error in IotHttpsClient_Connect(). Error code 203.

Hi @harIot,

Were you able to follow the instructions here in order to set up httpbin in the docker container with port mapping (i.e. by running docker run -p 80:80 kennethreitz/httpbin), as well as update httpsdemoprofileSERVER_ADDRESS in https_demo_profile.h?

Can you confirm that httpbin is running by either curling localhost or accessing http://localhost:80 in a web browser?

Hi @MuneebAWS,

Thank you for your replay. Yes it’s running on localhost, and i also edit
httpsdemoprofileSERVER_ADDRESS to my IP address and there is a problem with the connection. Do I need to do some more configuration for Host Machine ?

Hi @harIot,

Have you already tried setting httpsdemoprofileSERVER_ADDRESS to 127.0.0.1? Does curling 127.0.0.1 give you the same html page that is hosted on httpbin.org?

Additionally, can you supply the entire debug log that gets printed to the console when running the http_plain_text demo?

Hi @MuneebAWS


This is my current status

Hi @harIot,

Just to confirm, the result in both cases is exactly the same when connecting to 127.0.0.1 instead of 192.168.0.40, correct?

Hi @MuneebAWS

Yes i tried both ways but the result is the same.

Hi @harIot,

Can you enable network debug logs in iot_config.h, as well as debug logging for FreeRTOS+TCP in FreeRTOSIPConfig.h?

Additionally, can you capture your packets using Wireshark? You can compare the differences between your test against httpbin.org and your test against localhost.

Hi @MuneebAWS

Thank you for your answer. It looks that is a problem with source and destination packets, can you give some hints about how can i solve this.

Hi @harIot,

What is the problem you have observed specifically? Can you upload your Wireshark packet captures?

Hi @MuneebAWS

https://ibb.co/H2gZtBM https://ibb.co/nQnJ3tD

Hi @harIot,

Can you upload the *.pcapng packet capture files exported from Wireshark?

Hi @MuneebAWS

What’s the IP address assigned to the HTTP Client (should be around line 10 of the debug log)? It doesn’t seem to be part of your screenshot. Also, in the future, you can simply just paste the console output in a code block in your post, or upload it here compressed into a .zip or .tar.

Hi @MuneebAWS

httpbin: 192.168.0.40
http client : 192.168.0.114

httpbin.org works fine, what’s the problem with localhost?

Hi @harIot,

There only seem to be 41 packets in the capture, and only 2 related to 192.168.0.114 (both DHCP). There definitely should be more packets. Can you run the capture again, this time starting before you run the demo, and stopping after it crashes?

It would also be helpful if you were to supply the packet capture of a successful run against httpbin.org, also starting before the demo, and stopping the capture after the first iteration succeeds. You can compress both captures into a .zip and upload it here directly.
Thanks

Hi @MuneebAWS

log.zip (80.9 KB)

Hi @MuneebAWS

I found a solution in FreeRTOSConfig.h, configNETWORK_INTERFACE_TO_USE needs change to 2 for localhost.