connection = sipLoadBalancer.handleIncomingResponse(response);
if (connection != null) {
// Alter connection and dispatch
LayerHelper.resetDispatcher(response, NetworkManager.getInstance());
TargetTuple targetTuple = new TargetTuple(connection.getTransport(), //its already resolved, dont resolve
connection.getRemoteEndpoint().getHostName(),
connection.getRemoteEndpoint().getPort());
if(connection.getOutgoingEndpoint() != null){
targetTuple.setCLBEndpoint(true);
targetTuple.setBindIp(connection.getOutgoingEndpoint().
getHostName());
targetTuple.setBindPort(connection.getOutgoingEndpoint().
getPort());
}
if (connection.getLocalEndpoint() == null) {
if (connection.getTransport() == SipTransports.UDP_PROT) {
// The Via has already been resolved and there is no point to retry
// sending to that address fails, since it is UDP.
response.setRetryPolicy(SipServletMessageImpl.RetryPolicy.DONT_RETRY);
} else {
response.setRetryPolicy(SipServletMessageImpl.RetryPolicy.RETRY); //dont resolve again if failure
}
} else {
targetTuple.setCLBEndpoint(true);
targetTuple.setBindIp(connection.getLocalEndpoint().getHostName());
response.setRetryPolicy(SipServletMessageImpl.RetryPolicy.RESOLVE_AND_RETRY);
}
response.setResolvedRemote(targetTuple);
//Proxy response to set remote end-point
return false;