1 Reply Latest reply: Aug 30, 2016 11:16 PM by Denny Wu RSS

    Connect qlik sense server from local computer (developer computer) using .net sdk

    Denny Wu

      Hi friends,

      Im software developer, im newbie for Qlik product.

      I developing some analytic platform using qlik and connect using .net sdk.

      My app is like analytic platform, so need have feature like clone qvf, data reloading, create visualization from my platform.

       

      I developed it in my computer and connect to qlik sense desktop version. And its worked. Now i should host my app to public.

       

      When i move to qlik sense version server, i got issues. Currently those issue is about connection issue.

      My qliksense server used SSL. And worked.

      When i want connect from my app using .net sdk i dont know how to connect it.

      What i doing now is create ILocation and used AsDirectlyConnection and send param User Directory, User ID and certificate. Certificate generated from qlik sense qmc. And already add my public IP adress to white list IP in virtual proxy. (But my computer has Shared public IP, because i got 5 team member)

      But when i try run my apps, i got error "QMProduct time out operation".

       

      Any body can help me ?

       

      Oh yeah, that connect from my computer (developer computer), and i want use SSL (certificate) so i will got flexibility for future if have a lot env for my Apps.

       

      Regards,

      Denny Wu

        • Re: Connect qlik sense server from local computer (developer computer) using .net sdk
          Denny Wu

          My code is like this:

           

          static void Main(string[] args)

                  {

                      try

                      {

                          var location = CreateLocation();

                          using (var hub = location.Hub())

                          {

                              Console.WriteLine(hub.ProductVersion());

                          }

                      }

                      catch (Exception ex)

                      {

                          Console.WriteLine(ex.GetBaseException().Message);

                      }

                      Console.ReadKey();

                  }

           

           

                  private static ILocation CreateLocation()

                  {

                      var qlikConfig = QlikConfig.GetConfig();

                      // Qlik Sense Desktop.

                      var uri = new Uri(qlikConfig.URL);

                      ILocation location = Qlik.Engine.Location.FromUri(uri);

           

           

                      if (qlikConfig.Edition == "server")

                      {

                          var certificateName = qlikConfig.CertificateName;

                          X509Certificate2 x509 = new X509Certificate2();

                          var certificatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "certificates/client.pfx");

           

           

                          byte[] rawData = File.ReadAllBytes(certificatePath);

                          x509.Import(rawData, "", X509KeyStorageFlags.UserKeySet);

                          X509Certificate2Collection certificateCollection = new X509Certificate2Collection(x509);

                          // Defining the location as a direct connection to Qlik Sense Server

                          location.AsDirectConnection(qlikConfig.UserDirectory, qlikConfig.UserID, certificateCollection: certificateCollection);

                      }

                      else if (qlikConfig.Edition == "desktop")

                      {

                          location.AsDirectConnectionToPersonalEdition();

                      }

                      else

                      {

                          throw new Exception("Qlik edition not applicable.");

                      }

           

           

                      return location;

                  }