Resolved DNS thread issue using EM::next_tick() instead of sleep().