Author Topic: Problems connecting to Statserver usind java SDK  (Read 10095 times)

Offline arecher

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Problems connecting to Statserver usind java SDK
« on: April 16, 2014, 02:58:29 PM »
Hi,

I´m trying to connect to a statserver, using a sdk java application, in order to collect some statistics, but the application returns some exceptions (for example com.genesyslab.platform.commons.protocol.ProtocolException: Problems during registration), caused by: com.genesyslab.platform.commons.connection.ConnectionException: Connection is closed by remote peer.

Does anybody know what is causing this error?

Here is the code that I´m using to collect statistics:

package pack;

import com.genesyslab.platform.commons.protocol.Endpoint;
import com.genesyslab.platform.commons.protocol.ProtocolException;
import com.genesyslab.platform.commons.protocol.RegistrationException;
import com.genesyslab.platform.reporting.protocol.StatServerProtocol;
import com.genesyslab.platform.reporting.protocol.statserver.Notification;
import com.genesyslab.platform.reporting.protocol.statserver.NotificationMode;
import com.genesyslab.platform.reporting.protocol.statserver.StatisticMetric;
import com.genesyslab.platform.reporting.protocol.statserver.StatisticObject;
import com.genesyslab.platform.reporting.protocol.statserver.StatisticObjectType;
import com.genesyslab.platform.reporting.protocol.statserver.requests.RequestCloseStatistic;
import com.genesyslab.platform.reporting.protocol.statserver.requests.RequestOpenStatistic;

public class StatSample {

/**
* @param args
* @throws InterruptedException
* @throws IllegalStateException
* @throws ProtocolException
* @throws RegistrationException
*/
public static void main(String[] args) throws RegistrationException, ProtocolException, IllegalStateException, InterruptedException {

StatServerProtocol statServerProtocol = new StatServerProtocol(new Endpoint("statserver_lab", "SCTTX", 3100));
        statServerProtocol.setClientName("StatApp");
       
       
       
        statServerProtocol.setClientId(1);
       
        statServerProtocol.open();
        RequestOpenStatistic req = RequestOpenStatistic.create();
       
        StatisticObject object = StatisticObject.create();
        object.setObjectId("Analyst001");
        object.setObjectType(StatisticObjectType.Agent);
        object.setTenantName("Resources");
        object.setTenantPassword("");
       
        StatisticMetric metric = StatisticMetric.create();
        metric.setStatisticType("TotalLoginTime");
       
        Notification notification = Notification.create();
        notification.setMode(NotificationMode.Periodical);
        notification.setFrequency(5);
       
        req.setStatisticObject(object);
        req.setStatisticMetric(metric);
        req.setNotification(notification);
        req.setReferenceId(2);
       
        System.out.println(statServerProtocol.request(req));
       
        for (int i=0; i < 4; ++i) {
            System.out.println(statServerProtocol.receive(-1));
        }
        System.out.println(statServerProtocol.request(RequestCloseStatistic.create(2)));
        statServerProtocol.close();

}

}

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2752
  • Karma: 44
Re: Problems connecting to Statserver usind java SDK
« Reply #1 on: April 17, 2014, 09:04:17 AM »
Check your URI specification - is the port and hostname(IP) right? What says logs of the statserver - did you see some communication from your app?

I hope the code is just a "PoC" :-)

Offline arecher

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Problems connecting to Statserver usind java SDK
« Reply #2 on: April 17, 2014, 12:19:33 PM »
Hi Kubig,

Thanks for your answer.

Yes, I´ve made some modification only in function ( Endpoint("statserver_lab", "SCTTX", 3100)) to post it in the forum. The logs didn´t show anything. In command prompt, when I type the command: netstat -ano | find "3100", the answer is:

TCP  0.0.0.0:3100        0.0.0.0              LISTENING
TCP  (IP):3100              IP:60385          TIME_WAIT

And a few minutes later:

TCP  0.0.0.0:3100        0.0.0.0              LISTENING


I´m doing the requisition inside the statserver computer, i.e, the application that I´ve made is in the same place of the statserver application. 

So, I have some questions regarding this problem:
This is my first application in Genesys enviorement, so that´s possible that I´m doing somithing wrong.

Excluding the function ( Endpoint("statserver_lab", "SCTTX", 3100)), do you know if is that a function that I´ve forgot or some thing like this?
Is it possible that I´m doing wrong in some configuration, or  is it possible that statserver is blocking my requisition in this port?

In adition, I´ve asked for the genesys administration to confirm the parameter of the configurations, and I´m waiting for his answer.

Thanks

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2752
  • Karma: 44
Re: Problems connecting to Statserver usind java SDK
« Reply #3 on: April 17, 2014, 12:39:06 PM »
As first check the hostname and the port of the running statserver. Each installation and administrator has own port ranges and there is no "default" port number for statserver application. In general, range 3000-3999 is not used for statserver applications within Genesys solution, but as I wrote above, the port configuration is up to administrator

It does not seem that you have forgot some important function, but the code is little bit "beginner" (all is in main function), but this is not related to the Genesys. I strongly recommend you to read PSDK documentation, especially MessageBroker and Protocol Manager.

Offline arecher

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Problems connecting to Statserver usind java SDK
« Reply #4 on: April 17, 2014, 12:54:32 PM »
Thanks for your quick answer. I´ll check the parameters with Genesys administrator and as soon as I have the results I`ll post the results.

Offline arecher

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Problems connecting to Statserver usind java SDK
« Reply #5 on: May 28, 2014, 08:50:15 PM »
Hi,

I have another questions. I've asked the Genesys´s Administratior regarding this problem and he said the connection with Stat Server<-> application is dropping because I have to autenticate it (with login/password) before connecting to Stat Server. According the adminitrator, I have to connect with Configuration Server with a login/password and after this, request the statistics with the Stat Server.

So, is it possible to do this?  Do you know if Configuration Server has any specific function to enable requests to Stat Server. The main ideia is to enable application requests via Configuration Server to Stat Server.

If it´s possible, do you know if I have to use this function: ConfServiceFactory.CreateConfService()?

Here is the code that I´m using: 

package pack;


import java.net.URISyntaxException;

import com.genesyslab.platform.commons.protocol.Endpoint;
import com.genesyslab.platform.commons.protocol.ProtocolException;
import com.genesyslab.platform.commons.protocol.RegistrationException;
import com.genesyslab.platform.configuration.protocol.ConfServerProtocol;
import com.genesyslab.platform.configuration.protocol.types.CfgAppType;
import com.genesyslab.platform.reporting.protocol.StatServerProtocol;
import com.genesyslab.platform.reporting.protocol.statserver.Notification;
import com.genesyslab.platform.reporting.protocol.statserver.NotificationMode;
import com.genesyslab.platform.reporting.protocol.statserver.StatisticMetric;
import com.genesyslab.platform.reporting.protocol.statserver.StatisticObject;
import com.genesyslab.platform.reporting.protocol.statserver.StatisticObjectType;
import com.genesyslab.platform.reporting.protocol.statserver.requests.RequestCloseStatistic;
import com.genesyslab.platform.reporting.protocol.statserver.requests.RequestOpenStatistic;

public class StatSample {

/**
* @param args
* @throws InterruptedException
* @throws IllegalStateException
* @throws ProtocolException
* @throws RegistrationException
* @throws URISyntaxException
*/
public static void main(String[] args) throws RegistrationException, ProtocolException, IllegalStateException, InterruptedException, URISyntaxException {


Endpoint cfgServerEndpoint = new Endpoint("cfg_proxy", "XX.XX.XX.XX", 2020);
ConfServerProtocol protocol = new ConfServerProtocol(cfgServerEndpoint);
protocol.setClientName("cfg_proxy");
protocol.setClientApplicationType(CfgAppType.CFGSCE.asInteger());
protocol.setUserName("XXX");
protocol.setUserPassword("XXX");
protocol.open();




StatServerProtocol statServerProtocol = new StatServerProtocol(new Endpoint("statserver_lab", "SCTTXXX", 3100));
        statServerProtocol.setClientName("StatApp");
       
       
       
        statServerProtocol.setClientId(1);
       
       
       
        statServerProtocol.open();
        RequestOpenStatistic req = RequestOpenStatistic.create();
       
        StatisticObject object = StatisticObject.create();
        object.setObjectId("Analyst001");
        object.setObjectType(StatisticObjectType.Agent);
        object.setTenantName("Resources");
        object.setTenantPassword("");
       
        StatisticMetric metric = StatisticMetric.create();
        metric.setStatisticType("TotalLoginTime");
       
        Notification notification = Notification.create();
        notification.setMode(NotificationMode.Periodical);
        notification.setFrequency(5);
       
        req.setStatisticObject(object);
        req.setStatisticMetric(metric);
        req.setNotification(notification);
        req.setReferenceId(2);
       
        System.out.println(statServerProtocol.request(req));
       
        for (int i=0; i < 4; ++i) {
            System.out.println(statServerProtocol.receive(-1));
        }
        System.out.println(statServerProtocol.request(RequestCloseStatistic.create(2)));
        statServerProtocol.close();
       
        protocol.close();
       

}

}
   

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Problems connecting to Statserver usind java SDK
« Reply #6 on: May 28, 2014, 08:54:15 PM »
Not true, you can connect directly to the SS without any authentication.

Offline arecher

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Problems connecting to Statserver usind java SDK
« Reply #7 on: May 28, 2014, 09:00:05 PM »
But the Administrator is saying to me that the SS is configured to respond requests only if I first autenticate in configuration server. Do you know  if is it true?

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2752
  • Karma: 44
Re: Problems connecting to Statserver usind java SDK
« Reply #8 on: May 29, 2014, 11:49:43 AM »
No login/passwd authorization is not necessary, but the clientname use within the code must exists within Genesys configuration

Offline arecher

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Problems connecting to Statserver usind java SDK
« Reply #9 on: May 29, 2014, 12:31:09 PM »
Ok, thanks for quick answer.