1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

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 // If the packetListener got removed, then it was never run and
// we never received a response, inform the exception callback // we never received a response, inform the exception callback
if (removed && exceptionCallback != null) { if (removed && exceptionCallback != null) {
exceptionCallback.processException(new NoResponseException()); exceptionCallback.processException(new NoResponseException(AbstractXMPPConnection.this));
} }
} }
}, timeout, TimeUnit.MILLISECONDS); }, timeout, TimeUnit.MILLISECONDS);

View file

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

View file

@ -197,7 +197,7 @@ public class SASLAuthentication {
maybeThrowException(); maybeThrowException();
if (!authenticationSuccessful) { if (!authenticationSuccessful) {
throw new NoResponseException(); throw new NoResponseException(connection);
} }
} }
else { else {
@ -244,7 +244,7 @@ public class SASLAuthentication {
maybeThrowException(); maybeThrowException();
if (!authenticationSuccessful) { if (!authenticationSuccessful) {
throw new NoResponseException(); throw new NoResponseException(connection);
} }
} }
else { else {
@ -283,7 +283,7 @@ public class SASLAuthentication {
maybeThrowException(); maybeThrowException();
if (!authenticationSuccessful) { 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 * Exception thrown always when there was no response to an request within the packet reply timeout of the used
* timeout of the used connection instance. * connection instance. You can modify (e.g. increase) the packet reply timeout with
* {@link XMPPConnection#setPacketReplyTimeout(long)}.
*/ */
public static class NoResponseException extends SmackException { public static class NoResponseException extends SmackException {
/** /**
@ -63,8 +64,9 @@ public class SmackException extends Exception {
*/ */
private static final long serialVersionUID = -6523363748984543636L; private static final long serialVersionUID = -6523363748984543636L;
public NoResponseException() { public NoResponseException(XMPPConnection connection) {
super("No response received within packet reply timeout"); 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 Initial:
case NoResponse: case NoResponse:
case RequestSent: case RequestSent:
throw new NoResponseException(); throw new NoResponseException(connection);
default: default:
// Do nothing // Do nothing
break; break;

View file

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