How can I send an ACLMessage from a JADE Platform running on a windows to another JADE Platform running on a Raspberry pi (Raspbian)?

Viewed 279

I am trying to have a Multi-Agent System on a distributed network (a Windows computer and a Raspberry pi with Raspbian OS installed on). I start my jade platform on windows using this command:

java mylibrary jade.Boot -gui -platfrom-id Platform1 -agents starter:Starter

I also start my jade platform on Raspbian using this command:

java mylibrary jade.Boot -gui -platform-id Raspy1 -agents starter:Starter

This is Starter.java in both computers:

import jade.core.Agent;
import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;

import java.util.Arrays;

public class Starter extends Agent {

    @Override
    protected void setup() {
        System.out.println("Setup of starter agent");

        addBehaviour(new ReceiveBehaviour());

    }

    private class ReceiveBehaviour extends CyclicBehaviour {

        @Override
        public void action() {
            ACLMessage msg = myAgent.receive();
            if (msg != null) {
                System.out.println(msg.getContent());
                System.out.println(Arrays.toString(msg.getSender().getAddressesArray()));
                ACLMessage reply = msg.createReply();
                reply.setContent("I got it. Thank you " + msg.getSender().getName());
                myAgent.send(reply);
            } else {
                block();
            }
        }
    }
}

Also, this is the mtpaddress in my windows: http://192.168.1.6:7778/acc and this is the mtpaddress on my raspbian: http://raspy1:7778/acc

Both my computers are connected to a local network (a wireless modem) using wifi.

Now what happens is that, I start my platform on both computers, start a DummyAgent on windows and try to send a message to the raspbian platform. So I add a receiver and put the name and address like the image

below: DymmyAgent in my windows to send message to my raspberry

and this is the console output:

Mar 06, 2020 7:45:33 PM jade.core.messaging.MessagingService deliverNow
WARNING: Cannot deliver message to address: http://raspy1:7778/acc [jade.mtp.MTPException: raspy1 - Caused by:  raspy1]. Trying the next one...
Mar 06, 2020 7:45:33 PM jade.core.messaging.MessageManager$Deliverer run
WARNING: Deliverer Thread Deliverer-4 - Delivery-time over threshold (9322). Receiver = da0, message size = 301
( (action ( agent-identifier :name starter@Platform1  :addresses (sequence http://192.168.1.6:7778/acc )) (ACLMessage) ) (MTS-error ( agent-identifier :name da0@Raspy1  :addresses (sequence http://raspy1:7778/acc )) (internal-error "Foreign agent unreachable: No valid address contained within the AID da0@Raspy1")) )
[http://192.168.1.6:7778/acc]

I can send a message from a DummyAgent on raspberry to my windows platform but the opposite way wont happen. What can I do?

1 Answers

We are using JADE communication between different machines (Win, Linux, Mac) extensively in a distributed Smart Grid environment.

In order to allow communication between our agents, we have setup a central agent called CEA (short for Central Exectuion Agent) that serves a communication mediator between agents. E.g. he owns and maintains a central phonebook. All agents register themselves at this CEA agent. In turn, the CEA agent can provide the exact addresses of known application agents.

To register at the CEA, the agents needs to know the address of it. The address contains of the agents name, the platform name, the CEA's MTP-URL and MTP-port. In the example below you'll find how we configure an AID, if we are on different machines.

 public AID getAID(){

    String ceaName = this.getAgentName();
    String platformName = this.getPlatformName();
    String mtpProtocol = this.getMtpType();
    String mtpUrl = this.getUrlOrIp();
    int mtpPort = this.getMtpPort();

    String ceaGUID = ceaName + "@" + platformName;
    String ceaMTPAddress = mtpProtocol.toLowerCase() + "://" + mtpUrl + ":" + mtpPort + "/acc";

    AID aid = new AID(ceaGUID, true);
    aid.addAddresses(ceaMTPAddress);
    return aid;
}

So the most important thing is that in contrast to local ACLMessages (send between agents on the same platform), you need to add the MTP information for the remote JADE platform to the AID. I'm not sure, if the JADE visualization / UI is able to do that.

With respect to the shown MTP address of your R'Pi, I doubt that the URL http://raspy1:7778/acc can be resolved in your local network (unless you have a DNS running that translates 'raspy1'). Better you start both platforms with specific MTP settings so that IP addresses are used instead of names (Have a look at the JADE Adminstrator's Guide).

Related