Oliv4945 / eink

Fork of Sprite_tm E-Ink ESP8266 project. Sanitized and updated to compile with current tools (01/2017)
https://spritesmods.com/?art=einkdisplay
16 stars 4 forks source link

Numeric IP in datasource URL fails #3

Open fjansson opened 7 years ago

fjansson commented 7 years ago

If myConfig.url contains a numeric IP address, the connection does not succeed. If it contains a name which resolves to the same IP address, fetching data works.

The reason seems to be in httpclientFetch(), where espconn_gethostbyname() is called to resolve the hostname part of the URL. Once the name is resolved, this function calls a callback function which handles the rest of the connection. However, if the IP address is known immediately, espconn_gethostbyname() returns directly and does NOT call the callback function, which means that passing an IP address results in the connection failing.

I tried checking the return value of espconn_gethostbyname() and call the function myself. This still did not work, apparently because the network connection was not complete by the time this function was called. It seems espconn_gethostbyname() also provides a way here to ensure that the connection is up before proceeding.

This is an issue in the original code, but it is not on GitHub, so I post it here.

Oliv4945 commented 7 years ago

Hi @fjansson, You can try this forum, the author is one of the moderators.

Also, maybe you can use espconn_connect.
See this example they have a #ifdef DNS_ENABLE which can help you.