quarkiverse / quarkus-jdiameter

Quarkus JDiameter extension - Diameter protocol support
https://docs.quarkiverse.io/quarkus-jdiameter/2.0.0
GNU Affero General Public License v3.0
3 stars 2 forks source link

Diameter stack doesn't seem to start #41

Open franzgranlund opened 1 day ago

franzgranlund commented 1 day ago

Hi,

So I'm quite new to both Quarkus and jdiameter so I'm sorry if there is something I'm totally missing.

My goal is to create the most simple Diameter Rf Server. I followed the Implementing Diameter Service and got both Quarkus and the dependencies working and compiling.

I created a class CdfDiameterService.java like this:

@DiameterService
@DiameterServiceOptions("test1")
public class CdfDiameterService implements ServerRfSessionListener {
    @Override
    public void doRfAccountingRequestEvent(ServerRfSession appSession, RfAccountingRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
        Log.info("CdfDiameterService ---- doRfAccountingRequestEvent");

    }

    @Override
    public void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
        Log.info("CdfDiameterService ---- doOtherEvent");
    }
}

I added to application.properties:

quarkus.diameter.test1.local-peer.uri=aaa://127.0.0.1:3868
quarkus.diameter.test1.local-peer.ip-addresses=127.0.0.1
quarkus.diameter.test1.local-peer.realm=sip.myrealm.com
quarkus.diameter.test1.local-peer.product-name=Diameter Rf Server
quarkus.diameter.test1.local-peer.firmware-revision=1
quarkus.diameter.test1.local-peer.applications.0.vendor-id=10415
quarkus.diameter.test1.local-peer.applications.0.acct-appl-id=3

quarkus.diameter.test1.parameter.use-virtual-threads=true

quarkus.diameter.test1.network.peers."one".peer-uri=aaa://127.0.0.1:1812
quarkus.diameter.test1.network.peers."one".ip=127.0.0.1
quarkus.diameter.test1.network.peers."one".attempt-connect=false
quarkus.diameter.test1.network.peers."one".rating=0

quarkus.diameter.test1.network.realms."sip.myrealm.com".peers=127.0.0.1
quarkus.diameter.test1.network.realms."sip.myrealm.com".local-action=local
quarkus.diameter.test1.network.realms."sip.myrealm.com".dynamic=false
quarkus.diameter.test1.network.realms."sip.myrealm.com".exp-time=1
quarkus.diameter.test1.network.realms."sip.myrealm.com".application-id.vendor-id=10415
quarkus.diameter.test1.network.realms."sip.myrealm.com".application-id.acct-appl-id=3

Everything compiles but the diameter stack doesn't seem to start. Should it just work with only this?

I then tried creating a class CdfStack.java:

@ApplicationScoped
public class CdfStack {
    @DiameterConfig("alcom")
    Stack stack;

    @Startup
    void startup() throws IllegalDiameterStateException, InternalException {
        Log.info("Startup");
        //stack.start();
    }

    @Shutdown
    void shutdown() throws IllegalDiameterStateException, InternalException {
        Log.info("Shutdown");
        //stack.stop(1, TimeUnit.SECONDS, 0);
        //stack.destroy();
    }
}

If I uncomment stack.start() and stack.stop() / stack.destroy() then the diameter stack seem to start according to logs. I can even connect to it with a diameter client. But then the CdfDiameterServices doesn't seem to listen/trigger.

What am I doing wrong? I appreciate all the help I can get.

eddiecarpenter commented 1 day ago

Hi @franzgranlund The JDiameter stack is quite sensitive regarding its configuration and will silently ignore requests if not correctly configured.

You can start by increasing the "org. diameter" log level to TRACE and check if the requests are not rejected. quarkus.log.category."org.jdiameter".level=WARN

Starting the stack is done automatically by the quarkus-jdiameter extension. Your application will listen on port 3868 if the stack is successfully started.

franzgranlund commented 1 day ago

Thank you for your answer @eddiecarpenter .

So basically it should start, if I have the correct config, by just having the CdfDiameterService.java?

@DiameterService
@DiameterServiceOptions("test1")
public class CdfDiameterService implements ServerRfSessionListener {
    @Override
    public void doRfAccountingRequestEvent(ServerRfSession appSession, RfAccountingRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
        Log.info("CdfDiameterService ---- doRfAccountingRequestEvent");

    }

    @Override
    public void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
        Log.info("CdfDiameterService ---- doOtherEvent");
    }
} 

Also, should I use

@DiameterServiceOption(config = "test1")

or

@DiameterServiceOptions("test1")

?

eddiecarpenter commented 1 day ago

Hi @franzgranlund ,

The diameter service is registered by adding the @DiameterService annotation to the class. The interceptor behind the annotation will do all the work of registering the service, hooking it into the Quarkus shutdown service, and so on. The interface that you implement determines which diameter service you are implementing. In your case, you are implementing a RF Server. For example, if you want to implement a DCCA then you would implement the ServerCCASessionListener interface. There is a list of all the supported interfaces in the documentation.

The @DiameterServiceOption annotation is used to pass options to the interceptor, the most relative option being the configuration profile it should use. Note, that if used a default config (without the "test1." component, then you do not need to provide the @DiameterServiceOption annotation.

I see that the documentation was slightly outdated as I have changed the "config" attribute to "value". So, the correct format is @DiameterServiceOptions("test1")

I have updated the documentation.