To develop a Ethernet based Monitoring Device (read: HTTPClient) for a customer, we modified the qs_iot example from TivaWare_C_Series-2.1.4.178 to sent HTTP POST requests (with JSON body) to a Web Service developed by ourselves only.
For the implementation, we used a Public IP to expose the Web API and all HTTP POST operation was happening OK. There was no issue. The Device was able to send HTTP Post requests to the Web Service similar to what a PC based HTTP client does (such as ARC Advanced Rest Client). The product was tested OK.
Somedays back we had to move the Internet based Web Service to our LAN, which meant that the web service was now available in the LAN (over an IP 192.168.1.2).
Surprisingly, the device failed to send Data to the web service within our LAN and upon debugging, I found out that the function exoHAL_SocketOpenTCP(server) in exosite.c was failing with the message:
Err: Bad Socket (Issue with Internet or Server)
However the Device is able to procure an IP address from DHCP but somehow socket connection fails within the LAN.
Secondly, We again tried to send the HTTP POST request to a server based in the Internet (Public IP) and to my surprise, the same Firmware (only with change in API endpoint) works flawlessly from the same network.
In short, exoHAL_SocketOpenTCP() fails when the destination is within the LAN but works OK when the destination is a URL / Publc IP over the internet.
Some hints:
- I'm able to PING my Device (192.168.1.20) from the Server (192.168.1.2) within the LAN
- HTTP POST requests using a desktop based HTTP Client are OK (200) within the LAN
- I assigned the IP taken by the Device to my PC and then sent the HTTP POST request using a HTTP Client and it succeeds.
- So in short, Something is Wrong with the exoHAL which is caused the socket error.
Please help with the solution.
Thanks.