For standard ICE (RFC5245), send STUN binding indication keep-alives after ICE finished with COMPLETED state.
This commit is contained in:
parent
03a1a11644
commit
f8cb1a05b2
@ -1539,13 +1539,13 @@ public class Agent
|
|||||||
setState(IceProcessingState.COMPLETED);
|
setState(IceProcessingState.COMPLETED);
|
||||||
|
|
||||||
// keep ICE running (answer binding request)
|
// keep ICE running (answer binding request)
|
||||||
if(compatibilityMode == CompatibilityMode.GTALK
|
if(stunKeepAliveThread == null)
|
||||||
&& stunKeepAliveThread == null)
|
|
||||||
{
|
{
|
||||||
// schedule STUN checks for selected candidates
|
// schedule STUN checks for selected candidates
|
||||||
scheduleSTUNKeepAlive();
|
scheduleSTUNKeepAlive();
|
||||||
}
|
}
|
||||||
else if(compatibilityMode == CompatibilityMode.RFC5245)
|
|
||||||
|
if(compatibilityMode == CompatibilityMode.RFC5245)
|
||||||
{
|
{
|
||||||
scheduleTermination();
|
scheduleTermination();
|
||||||
}
|
}
|
||||||
@ -1951,7 +1951,8 @@ public class Agent
|
|||||||
*/
|
*/
|
||||||
public void runInStunKeepAliveThread()
|
public void runInStunKeepAliveThread()
|
||||||
{
|
{
|
||||||
while(state == IceProcessingState.COMPLETED)
|
while(state == IceProcessingState.COMPLETED || state ==
|
||||||
|
IceProcessingState.TERMINATED)
|
||||||
{
|
{
|
||||||
List<IceMediaStream> streams = getStreams();
|
List<IceMediaStream> streams = getStreams();
|
||||||
|
|
||||||
@ -1963,8 +1964,15 @@ public class Agent
|
|||||||
CandidatePair pair = cmp.getSelectedPair();
|
CandidatePair pair = cmp.getSelectedPair();
|
||||||
|
|
||||||
if(pair != null)
|
if(pair != null)
|
||||||
|
{
|
||||||
|
if(compatibilityMode == CompatibilityMode.GTALK)
|
||||||
{
|
{
|
||||||
connCheckClient.startCheckForPair(pair);
|
connCheckClient.startCheckForPair(pair);
|
||||||
|
}
|
||||||
|
else if(compatibilityMode == CompatibilityMode.RFC5245)
|
||||||
|
{
|
||||||
|
connCheckClient.sendBindingIndicationForPair(pair);
|
||||||
|
}
|
||||||
pair = null;
|
pair = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,6 +103,53 @@ class ConnectivityCheckClient
|
|||||||
paceMaker.start();
|
paceMaker.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a STUN Binding {@link Indication} to a candidate pair. It is used
|
||||||
|
* as a keep-alive.
|
||||||
|
*
|
||||||
|
* @param candidatePair that {@link CandidatePair} that we'd like to send
|
||||||
|
* an indication
|
||||||
|
*/
|
||||||
|
protected void sendBindingIndicationForPair(
|
||||||
|
CandidatePair candidatePair)
|
||||||
|
{
|
||||||
|
LocalCandidate localCandidate = candidatePair.getLocalCandidate();
|
||||||
|
|
||||||
|
Indication indication = MessageFactory.createBindingIndication();
|
||||||
|
|
||||||
|
TransactionID tran = TransactionID.createNewTransactionID();
|
||||||
|
tran.setApplicationData(candidatePair);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TransportAddress localAddr = localCandidate.getBase().
|
||||||
|
getTransportAddress();
|
||||||
|
|
||||||
|
stunStack.sendIndication(
|
||||||
|
indication,
|
||||||
|
candidatePair
|
||||||
|
.getRemoteCandidate().getTransportAddress(),
|
||||||
|
localAddr);
|
||||||
|
if(logger.isLoggable(Level.FINEST))
|
||||||
|
{
|
||||||
|
logger.finest(
|
||||||
|
"sending binding indication to pair " + candidatePair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
IceSocketWrapper stunSocket = localCandidate.getStunSocket(null);
|
||||||
|
if(stunSocket != null)
|
||||||
|
logger.log(
|
||||||
|
Level.INFO,
|
||||||
|
"Failed to send " + indication
|
||||||
|
+ " through " + stunSocket.getLocalSocketAddress(),
|
||||||
|
ex);
|
||||||
|
stunSocket = null;
|
||||||
|
tran = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a STUN {@link Request} containing the necessary PRIORITY and
|
* Creates a STUN {@link Request} containing the necessary PRIORITY and
|
||||||
* CONTROLLING/CONTROLLED attributes. Also stores a reference to
|
* CONTROLLING/CONTROLLED attributes. Also stores a reference to
|
||||||
|
|||||||
@ -79,6 +79,12 @@ public abstract class Message
|
|||||||
public static final char BINDING_ERROR_RESPONSE =
|
public static final char BINDING_ERROR_RESPONSE =
|
||||||
(STUN_METHOD_BINDING | STUN_ERROR_RESP);
|
(STUN_METHOD_BINDING | STUN_ERROR_RESP);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* STUN binding request code.
|
||||||
|
*/
|
||||||
|
public static final char BINDING_INDICATION =
|
||||||
|
(STUN_METHOD_BINDING | STUN_INDICATION);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* STUN shared secret request.
|
* STUN shared secret request.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -319,6 +319,19 @@ public class MessageFactory
|
|||||||
return createBindingErrorResponse(errorCode, null, null);
|
return createBindingErrorResponse(errorCode, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a default binding indication.
|
||||||
|
*
|
||||||
|
* @return a default binding indication.
|
||||||
|
*/
|
||||||
|
public static Indication createBindingIndication()
|
||||||
|
{
|
||||||
|
Indication bindingIndication = new Indication();
|
||||||
|
|
||||||
|
bindingIndication.setMessageType(Message.BINDING_INDICATION);
|
||||||
|
return bindingIndication;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an allocate request without attribute.
|
* Create an allocate request without attribute.
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user