8 Replies Latest reply on Aug 15, 2011 9:28 AM by calca

    TaskClient not connecting

    npereira

      Hi forum,

       

      I have been looking at JBPM5 API and I have a problem connecting to TaskClient from a different server.

       

      So I have my JBPM5.1 server, running.

      But from another machine I want to be able to connect to the JBPM5.1 and query the Human Task Service.

       

      Now the problem is that if I query it from localhost or 127.0.0.1, it works fine.

      TaskClient client = new TaskClient(new MinaTaskClientConnector("JBPM Interface", new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

      client.connect("127.0.0.1", 9123);

       

      But from another machine, running the same code, from another machine, it says that it cannot connect.

      TaskClient client = new TaskClient(new MinaTaskClientConnector("JBPM Interface", new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

      client.connect("10.1.5.13", 9123);

       

       

      Now I have tried this on diferent machine and the result is the same.

      I have read here in the forum that this is possible, even connect multiple machines to the same Human Task Service.

       

      Do I need to be looking at some configuration? (I have the install.demo config)

       

      Regards,

      Nelson

        • 1. TaskClient not connecting
          npereira

          Hi Guys,

           

          I have been going at it for a few days, and I can't quite understand why this issue is happening.

          My code is the following:

           

          TaskClient client = new TaskClient(new MinaTaskClientConnector("client 1", new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

                              if(client.connect("10.50.1.123", 9123))

                              {

                                        BlockingTaskSummaryResponseHandler taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler();

                                        client.getTasksAssignedAsPotentialOwner("krisv", "en-UK", taskSummaryResponseHandler);

           

                                        List<TaskSummary> tasks = taskSummaryResponseHandler.getResults();

             

           

                              }

                              else

                                        System.out.println("Not connected!!!!!");

           

          Everytime I try to connect from a different computer I keep gewtting the "Not Connected!!" message.

          Did any of you guys have this problem?

           

          Also I know that for Jboss you have the "./run.sh -b 0.0.0.0" command. Is there any command like this for Human Task Service?

           

          Thanks

          • 2. Re: TaskClient not connecting
            bpmn2user

            Did you try setting the properties using taskHandler.SetConnection?

            Try the following:

             

            CommandBasedWSHumanTaskHandler taskHandler = new CommandBasedWSHumanTaskHandler(ksession);

            taskHandler.setConnection("10.1.5.13", 9123);

            • 3. Re: TaskClient not connecting
              npereira

              Hi bpmn2user,

               

              Thanks for your reply, but unfortunatly I wasn't able to connect. I tried,

               

                      KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

                      KnowledgeBase kbase = kbuilder.newKnowledgeBase();

                      StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

                      CommandBasedWSHumanTaskHandler taskHandler = new CommandBasedWSHumanTaskHandler(ksession);

                      taskHandler.setConnection("10.1.5.148", 9123);       

                     taskHandler.connect();

                      TaskClient client = new TaskClient(new MinaTaskClientConnector("client 1", new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

               

                      taskHandler.setClient(client);

                      if(client.connect())

                          System.out.println("OK");

                      else

                          System.out.println("NOT OK");

               

              But on the highlighted line, I get the following error,

               

              Exception in thread "main" java.lang.IllegalArgumentException: Could not connect task client

                  at org.jbpm.process.workitem.wsht.CommandBasedWSHumanTaskHandler.connect(CommandBasedWSHumanTaskHandler.java:88)

               

               

              Does it make any sense to you? Is it something I'm missing in my code?

               

              Regards,

              Nelson

              • 4. Re: TaskClient not connecting
                calca

                Hi!

                 

                I think the Jbpm5 Mina server will not accept conections outsided 127.0.0.1. If you check the class

                 

                https://github.com/droolsjbpm/jbpm/blob/master/jbpm-human-task/src/main/java/org/jbpm/task/service/mina/BaseMinaTaskServer.java

                 

                The start() method configures the local interface used to accept connections:

                acceptor.bind( new InetSocketAddress( "127.0.0.1", port ) );

                 

                and this "127.0.0.1" will only accept local conections.

                 

                If we want to let clients from outside, should this parameter be configurable?

                • 5. TaskClient not connecting
                  npereira

                  Hi Demian,

                   

                  Thanks for the help.

                  It real seems that this is hard coded.

                   

                  I hope someone in the forum, can shed some light and if there is a the possibility to configure this parameter?

                   

                  Regards,

                  Nelson

                  • 6. TaskClient not connecting
                    calca

                    Opened a JIRA issue:

                    https://issues.jboss.org/browse/JBPM-3191

                     

                    Demian

                    • 7. Re: TaskClient not connecting
                      npereira

                      Hi forum,

                       

                      I have been monitoring this issue and I see that it has been resolved.

                       

                      I tried it out with the latest release but I'm still getting the same error?

                      Can you guys help me out!

                       

                      Regards

                      • 8. Re: TaskClient not connecting
                        calca

                        Have you tried creating the mina task server with binding all interfaces? Using this constructor:

                         

                        +public BaseMinaTaskServer(IoHandlerAdapter handler, int port,
                        +        String localInterface) {
                        +
                        this.handler = handler;
                        +
                        this.port = port;
                        +
                        this.localInterface = localInterface;
                        +}

                         

                        with localInterface = "0.0.0.0"

                         

                        BTW, you should try hornetQ based task client/server, which is more powerful (sending JMS messages, persist messages, include it in transactions).

                         

                        Regards,

                         

                        Demian