Skip to content

Commit

Permalink
feat: OF-2559 - surface session initialise timeout to a system property
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGidman committed Jul 18, 2023
1 parent 1dc18ec commit 880ef47
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions i18n/src/main/resources/openfire_i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,7 @@ system_property.xmpp.server.outgoing.max.threads=Minimum amount of threads in th
system_property.xmpp.server.outgoing.min.threads=Maximum amount of threads in the thread pool that is used to establish outbound server-to-server connections
system_property.xmpp.server.outgoing.threads-timeout=Amount of time after which idle, surplus threads are removed from the thread pool that is used to establish outbound server-to-server connections.
system_property.xmpp.server.outgoing.queue=Maximum amount of outbound server-to-server connections that can be in process of establishment in the thread pool (surplus connections will be created on the calling thread, possibly / gracefully slowing down other operations considerably)
system_property.xmpp.server.session.initialise-timeout=Maximum amount of time in seconds for an outbound S2S session to be initialised
system_property.cluster-monitor.service-enabled=Set to true to send messages to admins on cluster events, otherwise false
system_property.ldap.override.avatar=Set to true to save avatars in the local database, otherwise false
system_property.xmpp.domain=The XMPP domain of this server. Do not change this property directly, instead re-run the setup process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jivesoftware.openfire.server.OutgoingServerSocketReader;
import org.jivesoftware.openfire.server.RemoteServerManager;
import org.jivesoftware.openfire.server.ServerDialback;
import org.jivesoftware.util.SystemProperty;
import org.jivesoftware.util.TaskEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -34,6 +35,8 @@
import javax.annotation.Nonnull;
import java.net.Socket;
import java.net.SocketAddress;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -67,6 +70,16 @@ public class LocalOutgoingServerSession extends LocalServerSession implements Ou

private static final Interner<JID> remoteAuthMutex = Interners.newWeakInterner();

/**
* Controls the S2S outgoing session initialise timeout time in seconds
*/
public static final SystemProperty<Duration> INITIALISE_TIMEOUT_SECONDS = SystemProperty.Builder.ofType(Duration.class)
.setKey("xmpp.server.session.initialise-timeout")
.setDefaultValue(Duration.ofSeconds(5))
.setChronoUnit(ChronoUnit.SECONDS)
.setDynamic(true)
.build();

private OutgoingServerSocketReader socketReader;
private final Collection<DomainPair> outgoingDomainPairs = new HashSet<>();

Expand Down Expand Up @@ -254,7 +267,7 @@ private static LocalOutgoingServerSession createOutgoingSession(@Nonnull final D
// Wait for the future to give us a session...
sessionInitialiser = new NettySessionInitializer(domainPair, port, directTLS);
// Set a read timeout (of 5 seconds) so we don't keep waiting forever
return (LocalOutgoingServerSession) sessionInitialiser.init().get(5000, TimeUnit.MILLISECONDS);
return (LocalOutgoingServerSession) sessionInitialiser.init().get(INITIALISE_TIMEOUT_SECONDS.getValue().getSeconds(), TimeUnit.SECONDS);
}
catch (Exception e)
{
Expand Down

0 comments on commit 880ef47

Please sign in to comment.