IIoT - WebClient FB blocks task when DNS is not responding

I am using the WebClient FB of the IIoT library. When using urls with the domain name instead of the IP address, the function block contacts the DNS (Domain Name Server) to resolve the IP address. However, if the DNS is not reachable, the WebClient functionblock gets blocked for a certain amount of time. On my ctrlX node for 10s, on another ctrlX I have seen 20s. The task that is running the functionblock stops running while the functionblock is blocked. The issue can be reproduced by:

Use a 1:1 connection between the engineering PC and the ctrlX XF10 (no other connections on the ctrlX)
Manually configure a DNS server, the IP adress should not be the same as the ctrlX or the engineering PC

Send out an request through the WebClient function block, e.g. https://www.boschrexroth.com/

The function block gets stuck for 10 and then generates an error and shows RESOLVE_HOSTNAME_FAILED.

For the exampe below the task shows a max cycle time of 10001583us ~= 10s

There are two issues here:
The timeout of the request is not determined by the timeout of the functionblock (above the timout is set to 3s, the functionblock was blocked for 10s)
The functionblock stops its task from running, stopping all logic in the task from executing

Best reply by StefanH

Hello,

We apologize for the late response.

An optimization is planned here: Web Client SL: Replace SysSockGetHostByName in Web_Client FB by ResolveHostname.

This is, what we received as a possible work around:

Before calling the WebClient FB, the user could use a ResolveHostname FB from the Net Base Services library asynchronously to check whether the host name can be resolved. Thus whether the DNS server can be reached and only call the WebClient FB if the DNS server can be reached.

Declaration:

asyncProperty : NBS.AsyncProperty := (anAppName :=  'Application', tgTaskGroup := 'IEC-Tasks', tnTaskName := 'xxx',                                     udiTaskInterval := 20000 , usiTaskPrio := 20);

ip: NBS.IIPAddress;resolve: NBS.ResolveHostname := (itfAsyncProperty := asyncProperty, sHostname := sHostname, udiTimeout := 1000000);    

Implementation:

resolve(xExecute := TRUE, itfIPAddress := ip);

View original
3 replies