Skip to main content

A issue in sip-load-balancer

2 replies [Last post]
Joined: 2007-08-09
Points: 0

In function SIPBalancerForwarder.processNonDialogCreatingRequest
For the following scenario:
REGISTER is received from outside, and no NODE is available.
So first the (*) line, refer to below, will be executed. i.e. 500 response will be sent to the UAC.
While the function will continue, in the (**) line, sendingSipProvider will be set to internalSipProvider.
Then goes to the (***) line, the REGISTER message will be sent out from the internal port of the LB. I don't think that will cause problem, but the flow just looks not graceful.
So is that more graceful if just return after send 500 response to the UAC?

private void processNonDialogCreatingRequest(SipProvider sipProvider, Request originalRequest,
ServerTransaction serverTransaction, Request request) throws ParseException, InvalidArgumentException,
TransactionUnavailableException, SipException {
// CANCEL is hop by hop, so replying to the CANCEL by generating a 200 OK and sending a CANCEL
if (request.getMethod().equals(Request.CANCEL)) {
processCancel(sipProvider, originalRequest, serverTransaction);
if(logger.isLoggable(Level.FINEST)) {
logger.finest("got NON dialog creating request:\n " + request);
decreaseMaxForwardsHeader(sipProvider, request);

SIPNode sipNode = removeRouteHeadersMeantForLB(request);
if (!request.getMethod().equals(Request.ACK)) {
// Check if the node is still alive for subsequent requests
RouteHeader routeHeader = (RouteHeader) request.getHeader(RouteHeader.NAME);
Map parameters = null;
boolean isSIPNodePresent = true;
String callID = ((CallID) request.getHeader(CallID.NAME)).getCallId();
if(routeHeader != null ) {
SipURI route = ((SipURI)routeHeader.getAddress().getURI());
isSIPNodePresent = register.isSIPNodePresent(route.getHost(), route.getPort(), route.getTransportParam());
if(!isSIPNodePresent) {
if(logger.isLoggable(Level.FINEST)) {
logger.finest("node " + route + " is not alive anymore, picking another one ");
parameters = new HashMap();
Iterator routeParametersIt = route.getParameterNames();
while(routeParametersIt.hasNext()) {
String routeParameterName =;
String routeParameterValue = route.getParameter(routeParameterName);
parameters.put(routeParameterName, routeParameterValue);
addRouteToNode(originalRequest, serverTransaction, request, parameters);
} else {
SIPNode node = register.getGluedNode(callID);
// checking if the gleued node is still alive, if not we pick a new node
if(node == null || !register.isSIPNodePresent(node.getIp(), node.getPort(), node.getTransports()[0])) {
if(logger.isLoggable(Level.FINEST)) {
logger.finest("node " + node + " is not alive anymore, picking another one ");
node = register.stickSessionToNode(callID, null);
//we change the request uri only if the request is coming from the external side
if(sipProvider == externalSipProvider && node != null) {
if(logger.isLoggable(Level.FINEST)) {
logger.finest("request coming from external, setting the request URI to the one of the node " + node);
SipURI requestURI = (SipURI)request.getRequestURI();
} else if(sipProvider == externalSipProvider) {
(*) //No node present yet to forward the request to, thus sending 500 final error response
Response response = messageFactory.createResponse
// BYE coming from the callee by example
ViaHeader viaHeader = headerFactory.createViaHeader(
this.myHost, this.myPort, ListeningPoint.UDP, null);
// Add the via header to the top of the header list.
if(logger.isLoggable(Level.FINEST)) {
logger.finest("ViaHeader added " + viaHeader);
SipProvider sendingSipProvider = externalSipProvider;
if(sipProvider == externalSipProvider) {
(**) sendingSipProvider = internalSipProvider;
if(logger.isLoggable(Level.FINEST)) {
logger.finest("sending the request:\n" + request + "\n on the other side");
if(Request.ACK.equalsIgnoreCase(request.getMethod())) {
} else {
(***) ClientTransaction ctx = sendingSipProvider.getNewClientTransaction(request);

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-24
Points: 0

Thx, fix committed t the trunk in revision 5006 (
The same problem was present also on processDialogCreatingRequest method.
It has been fixed for both methods


Joined: 2006-01-09
Points: 0

Hmm, seems valid point, Thanks.
Next time use [_code][/_code] I think has formatters

Message was edited by: baranowb