mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-09 18:29:45 +02:00
Merge branch '4.3'
This commit is contained in:
commit
7a3f6f29cc
3 changed files with 97 additions and 13 deletions
|
@ -83,6 +83,7 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
|
|||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.SmackException.NotLoggedInException;
|
||||
import org.jivesoftware.smack.SmackException.SecurityRequiredByServerException;
|
||||
import org.jivesoftware.smack.SmackFuture;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.SynchronizationPoint;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
|
@ -388,6 +389,11 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
SSLSession sslSession = secureSocket != null ? secureSocket.getSession() : null;
|
||||
saslAuthentication.authenticate(username, password, config.getAuthzid(), sslSession);
|
||||
|
||||
// Wait for stream features after the authentication.
|
||||
// TODO: The name of this synchronization point "maybeCompressFeaturesReceived" is not perfect. It should be
|
||||
// renamed to "streamFeaturesAfterAuthenticationReceived".
|
||||
maybeCompressFeaturesReceived.checkIfSuccessOrWait();
|
||||
|
||||
// If compression is enabled then request the server to use stream compression. XEP-170
|
||||
// recommends to perform stream compression before resource binding.
|
||||
maybeEnableCompression();
|
||||
|
@ -552,7 +558,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
}
|
||||
}
|
||||
|
||||
private void connectUsingConfiguration() throws ConnectionException, IOException {
|
||||
private void connectUsingConfiguration() throws ConnectionException, IOException, InterruptedException {
|
||||
List<HostAddress> failedAddresses = populateHostAddresses();
|
||||
SocketFactory socketFactory = config.getSocketFactory();
|
||||
ProxyInfo proxyInfo = config.getProxyInfo();
|
||||
|
@ -571,14 +577,16 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
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();
|
||||
SmackFuture.SocketFuture socketFuture = new SmackFuture.SocketFuture(socketFactory);
|
||||
|
||||
final InetAddress inetAddress = inetAddresses.next();
|
||||
final String inetAddressAndPort = inetAddress + " at port " + port;
|
||||
LOGGER.finer("Trying to establish TCP connection to " + inetAddressAndPort);
|
||||
final InetSocketAddress inetSocketAddress = new InetSocketAddress(inetAddress, port);
|
||||
LOGGER.finer("Trying to establish TCP connection to " + inetSocketAddress);
|
||||
socketFuture.connectAsync(inetSocketAddress, timeout);
|
||||
|
||||
try {
|
||||
socket.connect(new InetSocketAddress(inetAddress, port), timeout);
|
||||
} catch (Exception e) {
|
||||
socket = socketFuture.getOrThrow();
|
||||
} catch (IOException e) {
|
||||
hostAddress.setException(inetAddress, e);
|
||||
if (inetAddresses.hasNext()) {
|
||||
continue innerloop;
|
||||
|
@ -586,7 +594,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
break innerloop;
|
||||
}
|
||||
}
|
||||
LOGGER.finer("Established TCP connection to " + inetAddressAndPort);
|
||||
LOGGER.finer("Established TCP connection to " + inetSocketAddress);
|
||||
// We found a host to connect to, return here
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
|
@ -856,7 +864,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
if (!config.isCompressionEnabled()) {
|
||||
return;
|
||||
}
|
||||
maybeCompressFeaturesReceived.checkIfSuccessOrWait();
|
||||
|
||||
Compress.Feature compression = getFeature(Compress.Feature.ELEMENT, Compress.NAMESPACE);
|
||||
if (compression == null) {
|
||||
// Server does not support compression
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue