PureEngage On-Premises

 View Only

Sign Up

  • 1.  "Connection is not opened" exception while sending request to protocolManagementService using statistic SDK

    Posted 07-13-2016 07:37
    Hi, 

    I am trying to recieve statistic notification using below code:

    //Initialize the protocol
      protocolManagementService = new ProtocolManagementService();
             statServerConfiguration = new StatServerConfiguration(STATSERVER_IDENTIFIER);
             try
             {
                 statServerUri = new Uri("tcp://"
                     + statServerHost
                     + ":"
                     + statServerport);
                 statServerConfiguration.Uri = statServerUri;
                 //statServerConfiguration.ClientName = 
                 // Register this connection configuration with Protocol Manager
                 protocolManagementService.Register(statServerConfiguration);
                 // Create and Initialize Message Broker Application Block
                 if (OpenProtocol())
                 {
                     eventBrokerService = new EventBrokerService(protocolManagementService.Receiver);
                     try
                     {
                         eventBrokerService.Register(
                             StatServerEventsHandler);
                     }
                     catch (ProtocolException ex)
                     { }
                     // Activate event broker service 
                     eventBrokerService.Activate();
                 }
                 else
                     objLog.Log("Protocol Not opened");
             }
             catch (Exception ex)
             {
                 objLog.Log(ex.Message);
             }


    //Open Statistic
    RequestOpenStatistic request = RequestOpenStatistic.Create();

                 // Statistic Object
                 //String selectedObjectTypeName = "Agent";
                 //StatisticObjectType selectedObjectType = StatisticObjectType.Agent; // Dummy default value
                 String selectedObjectTypeName = "DN";
                 StatisticObjectType selectedObjectType = StatisticObjectType.RegularDN; // Dummy default value
                 if (selectedObjectTypeName == "Agent")
                 {
                     selectedObjectType = StatisticObjectType.Agent;
                 }
                 else if (selectedObjectTypeName == "Place")
                 {
                     selectedObjectType = StatisticObjectType.AgentPlace;
                 }
                 else if (selectedObjectTypeName == "Queue")
                 {
                     selectedObjectType = StatisticObjectType.Queue;
                 }
                 else if (selectedObjectTypeName == "DN")
                 {
                     selectedObjectType = StatisticObjectType.RegularDN;
                 }

                 StatisticObject statisticObject =
                     StatisticObject.Create(
                             "3103111",
                             selectedObjectType,
                             TENANT_NAME);

                 // Metric
                 StatisticMetric statisticMetric = StatisticMetric.Create("TotalTime");
                 //StatisticMetric statisticMetric = StatisticMetric.Create("TotalAdjustedNumber");

                 // Notification
                 Notification notification = Notification.Create();
                 notification.Mode = NotificationMode.Periodical; // To get Notifications after every defined interval
                 notification.Frequency = NOTIFICATION_FREQUENCY;

                 request.StatisticObject = statisticObject;
                 request.StatisticMetric = statisticMetric;
                 request.Notification = notification;

                 // Need to set this reference id value. This reference id becomes statistic id for all 
                 // future requests on this statistic and needs to be specified when performing 
                 // any action on this statistic like closing, suspending or resuming etc.  
                 request.ReferenceId = STATISTIC_REFERENCE_ID;
                 objLog.Log(request.ToString());
                 protocolManagementService[STATSERVER_IDENTIFIER].Send(request);


    I am recieving protocol exception as "connection is not opened" in below code:
    protocolManagementService[STATSERVER_IDENTIFIER].Send(request);


  • 2.  RE: "Connection is not opened" exception while sending request to protocolManagementService using statistic SDK

    Posted 07-13-2016 11:26
    In posted code I cannot see you opened the protocol, check the available samples provided by Genesys where you can see how to correctly open and use the specified procotol.

    HTH!

    Regards,
    --Jakub--


  • 3.  RE: "Connection is not opened" exception while sending request to protocolManagementService using statistic SDK

    Posted 07-13-2016 12:10
    Jakub,

    Below is the code which i used for opening protocol:
     statServerProtocol = new StatServerProtocol(new Endpoint(statServerName, statServerUri));
                 //statServerProtocol.ClientName = statServerConfiguration.ClientName;
                 //statServerProtocol.ClientId = statServerConfiguration.ClientId.Value;
                 IConnectionConfiguration propertyCfg = new PropertyConfiguration();
                 propertyCfg.SetOption("protocol", "addp");
                 propertyCfg.SetOption("addp-timeout", "60");
                 propertyCfg.SetOption("addp-remote-timeout", "60");
                 propertyCfg.SetOption("addp-trace", "both");
                 statServerProtocol.Configure(propertyCfg);

    IProtocol protocol = protocolManagementService[STATSERVER_IDENTIFIER];

                 if (protocol.State == ChannelState.Closed)
                     protocol.BeginOpen();


  • 4.  RE: "Connection is not opened" exception while sending request to protocolManagementService using statistic SDK

    Posted 07-13-2016 12:32
    Are you using async methods? If no, you do not have to use BeginOpen() method. Try to use just Open() method and debug your application step-by-step.


  • 5.  RE: "Connection is not opened" exception while sending request to protocolManagementService using statistic SDK

    Posted 07-13-2016 12:47
    I tried using Open() instead of BeginOpen() and still getting same error.
    Below is the stack trace for the error:
    Genesyslab.Platform.Commons.Protocols.AbstractChannel.ThrowNotOpened()
       at Genesyslab.Platform.Commons.Protocols.DuplexChannel.Send(IMessage message)
       at StatServer.OpenStatistic()


  • 6.  RE: "Connection is not opened" exception while sending request to protocolManagementService using statistic SDK

    Posted 07-13-2016 13:22
    Dou you see the connection on StatServer level? Do you see the connection is opened?


  • 7.  RE: "Connection is not opened" exception while sending request to protocolManagementService using statistic SDK

    Posted 07-20-2016 15:42
    Use CCPulse+ and try to connect to the stat server first and see whether it is connecting or not. If not then the problem is not with the code. If yes then proceed with the further troubleshooting.