Add reply timeout to NoResponseException message

This commit is contained in:
Florian Schmaus 2014-11-12 12:27:36 +01:00
parent c81cd34561
commit def8fea05f
6 changed files with 16 additions and 14 deletions

View File

@ -1185,7 +1185,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// If the packetListener got removed, then it was never run and
// we never received a response, inform the exception callback
if (removed && exceptionCallback != null) {
exceptionCallback.processException(new NoResponseException());
exceptionCallback.processException(new NoResponseException(AbstractXMPPConnection.this));
}
}
}, timeout, TimeUnit.MILLISECONDS);

View File

@ -191,7 +191,7 @@ public class PacketCollector {
P result = nextResult(timeout);
cancel();
if (result == null) {
throw new NoResponseException();
throw new NoResponseException(connection);
}
XMPPErrorException.ifHasErrorThenThrow(result);

View File

@ -197,7 +197,7 @@ public class SASLAuthentication {
maybeThrowException();
if (!authenticationSuccessful) {
throw new NoResponseException();
throw new NoResponseException(connection);
}
}
else {
@ -244,7 +244,7 @@ public class SASLAuthentication {
maybeThrowException();
if (!authenticationSuccessful) {
throw new NoResponseException();
throw new NoResponseException(connection);
}
}
else {
@ -283,7 +283,7 @@ public class SASLAuthentication {
maybeThrowException();
if (!authenticationSuccessful) {
throw new NoResponseException();
throw new NoResponseException(connection);
}
}

View File

@ -54,8 +54,9 @@ public class SmackException extends Exception {
}
/**
* Exception thrown always when there was no response to an (IQ) request within the packet reply
* timeout of the used connection instance.
* Exception thrown always when there was no response to an request within the packet reply timeout of the used
* connection instance. You can modify (e.g. increase) the packet reply timeout with
* {@link XMPPConnection#setPacketReplyTimeout(long)}.
*/
public static class NoResponseException extends SmackException {
/**
@ -63,8 +64,9 @@ public class SmackException extends Exception {
*/
private static final long serialVersionUID = -6523363748984543636L;
public NoResponseException() {
super("No response received within packet reply timeout");
public NoResponseException(XMPPConnection connection) {
super("No response received within packet reply timeout. Timeout was " + connection.getPacketReplyTimeout()
+ "ms (~" + connection.getPacketReplyTimeout() / 1000 + "s)");
}
}

View File

@ -173,7 +173,7 @@ public class SynchronizationPoint<E extends Exception> {
case Initial:
case NoResponse:
case RequestSent:
throw new NoResponseException();
throw new NoResponseException(connection);
default:
// Do nothing
break;

View File

@ -48,9 +48,9 @@ import org.jivesoftware.smackx.si.packet.StreamInitiation;
*/
public class FaultTolerantNegotiator extends StreamNegotiator {
private StreamNegotiator primaryNegotiator;
private StreamNegotiator secondaryNegotiator;
private XMPPConnection connection;
private final StreamNegotiator primaryNegotiator;
private final StreamNegotiator secondaryNegotiator;
private final XMPPConnection connection;
private PacketFilter primaryFilter;
private PacketFilter secondaryFilter;
@ -178,7 +178,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
public InputStream call() throws XMPPErrorException, InterruptedException, SmackException {
Packet streamInitiation = collector.nextResult();
if (streamInitiation == null) {
throw new NoResponseException();
throw new NoResponseException(connection);
}
StreamNegotiator negotiator = determineNegotiator(streamInitiation);
return negotiator.negotiateIncomingStream(streamInitiation);