Show us the code you are using.
Probably, you have to have a time out in setup so if, after a certain time elapses when no connection has been established, a flag, say called offline, is set and the connection attempt is abandoned. In the loop(), you will somehow use this flag to prevent any periodic attempts to re-establish a connection.