mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
Do not re-use the Socket after connect() failed
Fixes SMACK-724.
This commit is contained in:
parent
f8c00533c7
commit
73fcbc6b27
1 changed files with 4 additions and 1 deletions
|
@ -554,7 +554,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
if (socketFactory == null) {
|
||||
socketFactory = SocketFactory.getDefault();
|
||||
}
|
||||
socket = socketFactory.createSocket();
|
||||
for (HostAddress hostAddress : hostAddresses) {
|
||||
Iterator<InetAddress> inetAddresses = null;
|
||||
String host = hostAddress.getFQDN();
|
||||
|
@ -575,6 +574,10 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
continue;
|
||||
}
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue