Can you share your code example or provide us with the pointers to reproduce the issue? Why is it that initially it takes around 20 to 40 seconds to connect to your network? Does that happen every time or only at the initial stage?
Have you added this in your main application? Or changed the SSID and PASSPHRASE in the wifi_config_dct.h? Did you used the "default wifi_config_dct.h" file in the "include" folder in WICED or added it to the application folder?
Did you face the same problem with other APs as well? Did you trying changing the AP?