Enhance handling of connection attempts when hitting the connection limit

Bug #529.