Reputation: 1
'I m trying to establish communication between a main JADE container running on one machine and a secondary remote container running on another machine within the same network. However, I'm encountering issues with connecting the remote container to the main one. Here's my setup:
I have a main container running with the following profile:
import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.core.Runtime;
import jade.wrapper.AgentContainer;
public class PlatformMain {
public static void main(String[] args) {
// Define platform parameters
String PLATFORM_IP = "IP address";
int PLATFORM_PORT = 1099;
String PLATFORM_ID = "MyPlatform";
Runtime rt = Runtime.instance();
// Platform
Profile pMain = new ProfileImpl(PLATFORM_IP, PLATFORM_PORT, PLATFORM_ID);
System.out.println("Launching a main-container..." + pMain);
AgentContainer mainContainerRef = rt.createMainContainer(pMain);
// Container
String containerName = "MyContainer1";
Profile pContainer = new ProfileImpl(PLATFORM_IP, PLATFORM_PORT, PLATFORM_ID);
pContainer.setParameter(Profile.CONTAINER_NAME, containerName);
pContainer.setParameter(Profile.GUI,"true");
System.out.println("Launching container " + containerName);
AgentContainer containerRef = rt.createAgentContainer(pContainer);
// RMA
createMonitoringAgents(mainContainerRef);
System.out.println("Platform initialized successfully");
createMyAgent(containerRef);
}
private static void createMonitoringAgents(AgentContainer container) {
// Implement method to create monitoring agents
}
private static void createMyAgent(AgentContainer container) {
// Implement method to create your agent
}
}
public class SecondaryRemoteContainer {
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("Usage: java -jar YourJarFileName.jar <main_container_ip>");
return;
}
String secondaryContainerIP = "localhost";
int secondaryContainerPort = 1099;
String secondaryContainerID = "SecondaryContainer";
String mainContainerIP = args[0];
Runtime rt = Runtime.instance();
// Platform
Profile secondaryContainerProfile = new ProfileImpl(secondaryContainerIP, secondaryContainerPort, secondaryContainerID);
secondaryContainerProfile.setParameter(Profile.MAIN_HOST, mainContainerIP);
System.out.println("Launching the secondary container..." + secondaryContainerProfile);
AgentContainer secondaryContainerRef = rt.createMainContainer(secondaryContainerProfile);
System.out.println("Secondary container initialized successfully");
}
}
When I run the secondary remote container on my local machine, it connects successfully to the main container. However, when I try to run it on another machine within the same network, I encounter the following error:
Error adding ICP jade.imtp.leap.JICP.JICPPeer@5eb5c224[Error: Not possible to launch JADE on a remote host (ip). Check the -host and -local-host options.]. Communication failure while joining agent platform: No ICP active jade.core.IMTPException: No ICP active
I've ensured that both machines are connected to the same Wi-Fi network. What could be causing this issue, and how can I resolve it?
Upvotes: 0
Views: 54
Reputation: 96
1° Check that your second computer can ping the first one on the port you set for jade (firewalls and co can block traffic)
2° We do not care about the second container IP. It is part of the main platform network so it will be retrieved and managed by it. You kept "localhost" so it cannot work.
* @param host is the IP of the host where the main-container should be listening to. A null value means use the default (i.e. localhost)
* @param platformID is the symbolic name of the platform, if different from default. A null value means use the default (i.e. localhost)
System.out.println("Create and Connect container "+containerName+ " to the host : "+host+", platformID: "+platformID+" on port "+port);
Runtime rti=Runtime.instance();
pContainer = new ProfileImpl(host,port, platformID);
pContainer.setParameter(Profile.CONTAINER_NAME,containerName);
distantContainerRef = rti.createAgentContainer(pContainer);
Upvotes: 0