From 5789a5e48ed4c0fc61cd233a3a4fb8c2096d197c Mon Sep 17 00:00:00 2001 From: George Vagenas Date: Tue, 3 Jul 2018 17:40:38 +0300 Subject: [PATCH] Make sure to pick only the B2BUA created AppliationSessions and don't attempt to deal with app session created for calls to RC numbers This refer to BS-390 --- .../restcomm/connect/telephony/api/util/B2BUAHelper.java | 8 ++++++-- .../java/org/restcomm/connect/telephony/CallManager.java | 4 +++- .../org/restcomm/connect/telephony/CallManagerProxy.java | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/util/B2BUAHelper.java b/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/util/B2BUAHelper.java index 19be02e919..b471754831 100644 --- a/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/util/B2BUAHelper.java +++ b/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/util/B2BUAHelper.java @@ -71,7 +71,7 @@ * @author gvagenas@telestax.com */ public class B2BUAHelper { - + public static final String B2BUA_CALL = "org.restcomm.connect.telephony.api.util.B2BUAHelper"; public static final String FROM_INET_URI = "fromInetURI"; public static final String TO_INET_URI = "toInetURI"; public static final String B2BUA_LAST_REQUEST = "lastRequest"; @@ -238,6 +238,8 @@ public static boolean redirectToB2BUA(final ActorSystem system, final SipServlet sendCallInfoStreamEvent(system, request, CallStateChanged.State.QUEUED); + outgoingSession.getApplicationSession().setAttribute(B2BUA_CALL, "Client-To-Client"); + return true; // successfully proxied the SIP request between two registered clients } } catch (Exception e) { @@ -420,6 +422,8 @@ public static boolean redirectToB2BUA(final ActorSystem system, final SipServlet sendCallInfoStreamEvent(system, request, CallStateChanged.State.QUEUED); + outgoingSession.getApplicationSession().setAttribute(B2BUA_CALL, "Client-To-Client"); + return true; // successfully proxied the SIP request } catch (IOException exception) { if (logger.isInfoEnabled()) { @@ -880,7 +884,7 @@ public static void dropB2BUA(SipApplicationSession application) { logger.debug("sending BYE"); } createRequest.send(); - } catch (IOException ex) { + } catch (IOException | IllegalStateException ex) { logger.debug("Unable to drop session.", ex); } } diff --git a/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/CallManager.java b/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/CallManager.java index aa5504a4a3..1112cdc7e9 100644 --- a/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/CallManager.java +++ b/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/CallManager.java @@ -2448,7 +2448,9 @@ public void timeout(final Object message) { final SipApplicationSession application = event.getApplicationSession(); final ActorRef call = (ActorRef) application.getAttribute(Call.class.getName()); if (call == null) { - B2BUAHelper.dropB2BUA(application); + if (application.isValid()) { + B2BUAHelper.dropB2BUA(application); + } } //if there is Call actor, session was set to never expired, since Call //Akka actor is handling its own call expiration. so, do nothing in that case diff --git a/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/CallManagerProxy.java b/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/CallManagerProxy.java index 08d079d2cf..2dca72ac6f 100644 --- a/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/CallManagerProxy.java +++ b/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/CallManagerProxy.java @@ -29,6 +29,7 @@ import org.restcomm.connect.dao.DaoManager; import org.restcomm.connect.mscontrol.api.MediaServerControllerFactory; import org.restcomm.connect.sms.SmsService; +import org.restcomm.connect.telephony.api.util.B2BUAHelper; import org.restcomm.connect.ussd.telephony.UssdCallManager; import javax.servlet.ServletConfig; @@ -227,7 +228,7 @@ public void sessionExpired(SipApplicationSessionEvent sase) { //check attribute signlling Akka actor completed timeout processing //if att is present, let the sesion just expire logger.debug("Session expired"); - if (sase.getApplicationSession().getAttribute(CallManager.TIMEOUT_ATT) == null) { + if (sase.getApplicationSession().getAttribute(B2BUAHelper.B2BUA_CALL) != null && sase.getApplicationSession().getAttribute(CallManager.TIMEOUT_ATT) == null) { logger.debug("Session expired still not processed"); //extend expiration a bit,to let sessions be properly disconnected sase.getApplicationSession().setExpires(EXPIRATION_GRACE_PERIOD);