Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diameter stack doesn't seem to start #41

Closed
franzgranlund opened this issue Sep 17, 2024 · 6 comments · Fixed by #46
Closed

Diameter stack doesn't seem to start #41

franzgranlund opened this issue Sep 17, 2024 · 6 comments · Fixed by #46

Comments

@franzgranlund
Copy link
Contributor

franzgranlund commented Sep 17, 2024

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
Copy link
Member

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
Copy link
Contributor Author

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
Copy link
Member

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.

@eddiecarpenter
Copy link
Member

Hi @franzgranlund,
Have you managed to resolve your issue?

@franzgranlund
Copy link
Contributor Author

franzgranlund commented Sep 20, 2024

Hi @eddiecarpenter!

Yes, I finally managed to get the diameter stack started! Basically the only thing I needed to do was to inject the CdfDiameterService.java into some @ApplicationScoped class. Then the stack started and I got it configured. I'm not sure if this is the intended way but it does work for me.

So if anyone comes across this thread, this works for me to get a Rf Server running (quarkus-jdiameter 2.0.5):

CdfDiameterService.java

@DiameterService
public class CdfDiameterService implements ServerRfSessionListener {
    @Override
    public void doRfAccountingRequestEvent(ServerRfSession appSession, RfAccountingRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
        Log.info("CdfDiameterService ---- doRfAccountingRequestEvent");
        Log.info("e=doRfAccountingRequestEvent, session_id=" + appSession.getSessionId());
    }

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

CdfStack.java

@ApplicationScoped
public class CdfStack {
    @Inject
    CdfDiameterService service;

    @Startup
    void startup() {
        Log.info("Startup");
        Log.info("CdfDiameterService is " + service.toString());
    }

    @Shutdown
    void shutdown() {
        Log.info("Shutdown");
    }
}

application.properties

quarkus.diameter.local-peer.uri=aaa://127.0.0.1:3870
quarkus.diameter.local-peer.ip-addresses=127.0.0.1
quarkus.diameter.local-peer.realm=my.realm.com
quarkus.diameter.local-peer.product-name=RfServer
quarkus.diameter.local-peer.firmware-revision=1
quarkus.diameter.local-peer.applications.0.acct-appl-id=3

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

quarkus.diameter.network.realms."my.realm.com".peers=127.0.0.1
quarkus.diameter.network.realms."my.realm.com".local-action=local
quarkus.diameter.network.realms."my.realm.com".dynamic=false
quarkus.diameter.network.realms."my.realm.com".exp-time=1
quarkus.diameter.network.realms."my.realm.com".application-id.acct-appl-id=3

Thank you again @eddiecarpenter for your help!

@eddiecarpenter
Copy link
Member

I reckon you have found a startup bug :-)

@eddiecarpenter eddiecarpenter linked a pull request Sep 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants