2

i need to send some messages from my java web application to some servers using Diameter protocol, in particular CCR-CCA scenario. I had a look at jdiameter opensource project, but my usecase does not require such complexity, since that i just need to send a single request and log the response (actually i don't even need the CER-CEA part). So i thought i could just have used Seagull running under my webapp. I downloaded Seagull (for Windows), and what i'm trying to do is basically to run the .bat file coming from Seagull for the diameter environment from my java environment.

That's what i've done till now..

1) A simple test to invoke the client.. Here wrapper simply sets working dir and starts the process

public static void main(String[] args) {
        List<String> cmd=new ArrayList<>();
        cmd.add("cmd.exe");
        cmd.add("/c");
        cmd.add("my_start_client.bat");
        JavaProcessBuilderWrapper wrapper = new JavaProcessBuilderWrapper();
        Process p = wrapper.createProcess(RedirectErrorsTo.STDERR,
                new HashMap<>(), new File("my_working_dir"), cmd);

        BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));

        StringBuilder output = new StringBuilder();
        String line;
        try {
            while ((line = reader.readLine()) != null) {
                output.append(line);
            }
            System.out.println(line);

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

2) I modified the client's and server's .bat files coming from Seagull to use CCR-CCA protocol.

Running Java main with this configuration caused a

Fatal: Keyboard saved configuration failure error

on my logs.

3) So, as mentioned here i further modified my client's .bat file to run in background mode, adding -bg at the end. Now my client's bat look like this

@ECHO OFF
rem
 "Diameter Start Script Sample"
 "Local env"
 SET RUN_DIR=C:\Program Files\Seagull

 set PATH=%PATH%;%RUN_DIR%
 set LD_LIBRARY_PATH=%RUN_DIR%
 set RUN_DIR=%RUN_DIR%\diameter-env\run

 cd %RUN_DIR%
 cls
 mode 81,25
 echo "Seagull Diameter Client Sample Start"
seagull -conf ..\config\conf.client.xml -dico ..\config\base_ro_3gpp.xml -scen ..\scenario\ccr-cca.ro.client.xml -log ..\logs\ccr-cca.client.log -llevel ETM -bg

 pause

Since i was facing some troubles, to keep things simple, i just tried to make it work at least via cmd (not using my java method), but i think background mode is messing around, because now when i start my server and then my client in bg mode, sometimes i get a

Fatal: Forking error

but the most of the times, the client send a single message and then on my console i see that my software is causing connection abort (error code -1), and from the log i see that the channel just get closed, and my client does not even receive an answer. (NB for now i left the configuration files untouched)

Has any of you faced this behaviour? Is something else closing the connection (firewall perhaps)? Do i have to provide other configurations to make this work?

Once i can get this working, can i use my java web app (with a method similar to the one i already mentioned) to make diameter calls?

Thanks in advance, any help is really welcomed.

Danilo
  • 31
  • 2

1 Answers1

0

Fatal: Keyboard saved configuration failure is a manifestation that seagull cannot allocate TTY.

You would need to use something like Pty4j and allocate it, below a snippet:

var cmd = new String[]{""};
PtyProcess process = PtyProcess.exec(cmd);

// Now the process runs under a pseudo terminal,
// And the results are redirected back like the regular Java's Process class
redirectToRightPlace(process.getInputStream());
redirectToRightPlace(process.getErrorStream());
redirectToRightPlace(process.getOutputStream());

int exitCode = process.waitFor();
Jarek
  • 782
  • 5
  • 16