Close socket in Discovery.search

Without closing the socket Discovery.search can be called at most one time.