diff --git a/doc/configuration-options.md b/doc/configuration-options.md new file mode 100644 index 00000000..6e07b937 --- /dev/null +++ b/doc/configuration-options.md @@ -0,0 +1,27 @@ +## Configuration Options + +Configuration file: sip-communicator.properties
+Location of file depends on your installation type, possible locations are /HOME/.sip-communicator and /etc/jitsi + +Connection Options +------------------ +Pings are sent to determine whether or not a valid connection still exists. There are several configuration +properties you can set to fine tune this behavior. + +The name of the property which configures ping interval in ms. -1 to disable pings.
+property: **org.jitsi.*componentName*.PING_INTERVAL**
+default: 10000 ms + +The name of the property used to configure ping timeout in ms.
+property: **org.jitsi.*componentName*.PING_TIMEOUT**
+default: 5000 ms + +The name of the property which configures {@link #pingThreshold}.
+property: **org.jitsi.*componentName*.PING_THRESHOLD**
+default: 3 + +The name of the property used to determine if we should reconnect on ping failures. Setting this value to true will +force the connection to be reset when the ping threshold is reached
+property: **org.jitsi.*componentName*.RECONNECT_ON_PING_FAILURES**
+default: false + diff --git a/pom.xml b/pom.xml index 7dd85430..52cc16b5 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,7 @@ ${project.groupId} jitsi-protocol-jabber - 2.9-20151214.211356-5 + 2.9-20160505.143533-15 ${project.groupId} @@ -98,6 +98,19 @@ + + + inin-release + ININ Release Repository + http://purecloud.artifactoryonline.com/purecloud/inin-release + + + inin-snapshot + ININ Snapshot Repository + http://purecloud.artifactoryonline.com/purecloud/inin-snapshot + + + jitsi-maven-repository-releases diff --git a/src/main/java/org/jitsi/xmpp/component/ComponentBase.java b/src/main/java/org/jitsi/xmpp/component/ComponentBase.java index 3f8e9e46..98c05f8a 100644 --- a/src/main/java/org/jitsi/xmpp/component/ComponentBase.java +++ b/src/main/java/org/jitsi/xmpp/component/ComponentBase.java @@ -66,6 +66,13 @@ public abstract class ComponentBase public final static String PROCESSING_TIME_LIMIT_PNAME = "PROCESSING_TIME_LIMIT"; + /** + * The name of the property used to determine if we should + * reconnect on ping failures + */ + private final static String RECONNECT_ON_PING_FAILURES + = "RECONNECT_ON_PING_FAILURES"; + /** * The hostname or IP address to which this component will be connected. */ @@ -123,6 +130,12 @@ public abstract class ComponentBase */ private int pingFailures = 0; + /** + * If we exceed the maximum number of ping failures should we trigger a + * reconnect to the xmpp server + */ + private boolean reconnectOnPingFailure = false; + /** * Time used to schedule ping and timeout tasks. */ @@ -197,10 +210,14 @@ protected void loadConfig(ConfigurationService config, configPropertiesBase + PROCESSING_TIME_LIMIT_PNAME, DEFAULT_PROCESSING_TIME_LIMIT); + reconnectOnPingFailure = config.getBoolean( + configPropertiesBase + RECONNECT_ON_PING_FAILURES, false); + logger.info("Component " + configPropertiesBase + " config: "); logger.info(" ping interval: " + pingInterval + " ms"); logger.info(" ping timeout: " + pingTimeout + " ms"); logger.info(" ping threshold: " + pingThreshold); + logger.info(" reconnect on ping failures: " + reconnectOnPingFailure); } /** @@ -277,6 +294,7 @@ public void preComponentShutdown() } timeouts.clear(); + pingFailures = 0; } } @@ -295,6 +313,24 @@ public boolean isConnectionAlive() } } + /** + * Restart the component connection if we have exceeded the + * threshold for ping failures + */ + public void reconnectComponent() { + // need to make externalComponent here + logger.info("Restarting xmpp component connection that failed"); + shutdown(); + timeouts.clear(); + try { + compMan.removeComponent(this.getSubdomain()); + dispose(); + compMan.addComponent(getSubdomain(), this); + } catch (Exception ex) { + logger.error("Failed to restart xmpp component"); + } + } + /** * {@inheritDoc} * @@ -627,8 +663,11 @@ public void run() pingFailures++; logger.error("Ping timeout for ID: " + packetId); - timeouts.remove(packetId); + + if(!isConnectionAlive() && reconnectOnPingFailure) { + reconnectComponent(); + } } } }