Do not re-use the Socket after connect() failed

Fixes SMACK-724.
This commit is contained in:
Florian Schmaus 2016-06-19 12:06:21 +02:00
parent 1f87185ee8
commit fb55b9065f
1 changed files with 4 additions and 0 deletions

View File

@ -579,6 +579,10 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
throw new UnknownHostException(host);
}
innerloop: while (inetAddresses.hasNext()) {
// Create a *new* Socket before every connection attempt, i.e. connect() call, since Sockets are not
// re-usable after a failed connection attempt. See also SMACK-724.
socket = socketFactory.createSocket();
final InetAddress inetAddress = inetAddresses.next();
final String inetAddressAndPort = inetAddress + " at port " + port;
LOGGER.finer("Trying to establish TCP connection to " + inetAddressAndPort);