jcktej / jdiameter

Automatically exported from code.google.com/p/jdiameter
0 stars 0 forks source link

Processing requests for the same Diameter session #69

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Mail list item: 
https://groups.google.com/forum/#!topic/mobicents-public/zt05tnTQYBI

I had a problem a while ago if you get two Diameter requests quite close 
together (e.g. Ro CCR-U's for same session ID but different rate-group) - the 
RA processing uses the "last-request" concept and can mix up the end-to-end and 
hop-by-hop id.

I fixed this with the following when processing CCR's in my SBB:
RoCreditControlAnswer CCA = null;
        try {
            RoServerSessionActivity serverSession = (RoServerSessionActivity) aci.getActivity();
            CCA = serverSession.createRoCreditControlAnswer();
            CCA.getHeader().setEndToEndId(event.getHeader().getEndToEndId());
            CCA.getHeader().setHopByHopId(event.getHeader().getHopByHopId());

This ensures the correct values are used in the CCA and works fine.

Next issue I noted is that CC-Request-Number AVP suffered from exactly the same 
problem - if you get two very close CCR-Us for the same session-ID the 
cc-request-number can get mixed up.

I fixed this with the following in my SBB:
CCA.setCcRequestNumber(event.getCcRequestNumber());

But this causes an issue:

setCcRequestNumber() does not replace the cc-request-number AVP - it adds 
another one.

Having 2 cc-request-number AVP in a CCA can have issues with vendor Diameter 
clients.

I've fixed this with the following change:
+++ 
main/java/org/mobicents/slee/resource/diameter/ro/events/RoCreditControlMessageI
mpl.java    (working copy)
@@ -27,6 +27,7 @@
 import net.java.slee.resource.diameter.cca.events.avp.MultipleServicesCreditControlAvp;
 import net.java.slee.resource.diameter.ro.events.RoCreditControlMessage;
 import net.java.slee.resource.diameter.ro.events.avp.ServiceInformation;
+import org.jdiameter.api.Avp;

 import org.jdiameter.api.Message;
 import org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl;
@@ -63,7 +64,10 @@
    */
   @Override
   public void setCcRequestNumber(long ccRequestNumber) throws IllegalStateException {
-    addAvp(CreditControlAVPCodes.CC_Request_Number, ccRequestNumber);
+      if(hasCcRequestNumber()) {
+      
this.message.getAvps().removeAvp(CreditControlAVPCodes.CC_Request_Number);
+      }
+      addAvp(CreditControlAVPCodes.CC_Request_Number, ccRequestNumber);
   }

Original issue reported on code.google.com by richard....@smilecoms.com on 15 Dec 2014 at 9:58