diff --git a/features/netsocket/nsapi_dns.cpp b/features/netsocket/nsapi_dns.cpp index 0c9249173c6..47119a2d953 100644 --- a/features/netsocket/nsapi_dns.cpp +++ b/features/netsocket/nsapi_dns.cpp @@ -1021,7 +1021,14 @@ static void nsapi_dns_query_async_send(void *ptr) err = query->socket->sendto(dns_addr, packet, len); if (err < 0) { - query->dns_server++; + if (err == NSAPI_ERROR_WOULD_BLOCK) { + nsapi_dns_call_in(query->call_in_cb, DNS_TIMER_TIMEOUT, mbed::callback(nsapi_dns_query_async_send, ptr)); + free(packet); + dns_mutex->unlock(); + return; // Timeout handler will retry the connection if possible + } else { + query->dns_server++; + } } else { break; }