12 Replies Latest reply: Oct 10, 2014 4:17 AM by Johan Tejle RSS

    Sense .NET API, QMC configurations needed?

    Markus Rytkölä

      Do you need to do some configuration in QMC or your local Windows settings to get your .NET Windowsforms to connect to Sense?

       

      I have read the Betahelp for Sense API, but I cannot seem to get around the error, everything compiles fine but I keep geeting a Sockets.SocketException which says 'no connection could be made because target machine actively refused it 127.0.0.1:4848'

       

      Turned off firewall and went through QMC but nothing, I did notice that the port for Engine in QMC is 4747, not 4848, but I guess that's the way it should be.

       

      Any advice? Have anyone tried the .NET API for Sense and have a short and sweet code example to share

        • Re: Sense .NET API, QMC configurations needed?
          Lars-Goran Book
          var localSenseEngine = Qlik.Engine.Location.Local;
          var appIdentifier = localSenseEngine.AppWithName("myAppName.qvf");
          using (IApp app = localSenseEngine.App(appIdentifier))
          {
              ...
          }
          

           

          For more information see .Net SDK help

          https://help.qlik.com/sense/en-us/developer/index.html#../Subsystems/NetSdk/Content/Introduction/NetSdk_Intro.htm

            • Re: Sense .NET API, QMC configurations needed?
              Markus Rytkölä

              Hmm, no. not working.

               

              My code looks like this

               

                ILocation myLocation = Qlik.Engine.Location.Local;

                      using (IHub hub = myLocation.Hub())

                      {

              MessageBoxShow(hub.QvVersion());

                      }


              which results in SocketException "No connection could be made because the target machine actively refused it 127.0.0.1:4848"


              I have tried running the Qlik Sense services with Local System, a specific Sense user with Admin rights, checked the firewalls etc... hmm, I cannot see what the problem is.

                • Re: Re: Sense .NET API, QMC configurations needed?
                  Michael Tarallo

                  Hi Markus -

                   

                  Some clarifications / questions:

                   

                  • Is this a new install of the full Qlik Sense platform 1.0?
                  • This has nothing to do with Qlik Sense Desktop I assume?
                    • 127.0.0.1:4848 - is what Qlik Sense Desktop uses - and there isn't' any QMC
                    • When running the full platform - you should not get the above error - only if Qlik Sense Desktop is running
                  • Are you performing all dev work for this example on the same machine?
                  • Did you completely remove - uninstall any older versions, beta versions etc.
                  • If you access https://localhost/qmc - what happens? - Full Qlik Sense Platform with QMC
                  • If you access https://localhost/hub - what happens? - Full Qlik Sense Platform with QMC
                  • if you access http://localhost:4848/hub what happens?  - Qlik Sense Desktop

                   

                  We have seen this in a couple of situations (with Qlik Sense Desktop) when a proxy is being used - can you check your internet connection settings and see if you can bypass proxy for local address is checked?

                   

                   

                  Depending on the answers for the above questions - we have also seen where a previous releases' certificates may need to be removed.

                   

                  1. Stop Qlik Sense Repository Service (this will also stop the other services)
                  2. Open Microsoft Management Console (MMC). Important: Run this as the account configured to run the services (Run as... )
                  3. Add snap-in for Certificates: My user account and Local Computer account
                  4. In Certificates - Current User > Trusted Root Certification Authorities > Certificates, delete the certificate created by QlikSense, issued by your computer, computer.domain-CA
                  5. In Certificates > Current User > Personal > Certificates, delete the certificate named QlikClient
                  6. In Certificates (Local Computer) > Personal > Certificates, delete the certificate issued by computer.domain-CA.
                  7. Start Qlik Sense Repository Service and verify it created the new certificates
                  8. Start the rest of the services

                   

                  When logging in to https://localhost/qmc - you can just ignore the certificate error and depending on the borwser you are using, just trust it and accept it - for now. You can also choose to enable http - once you get into the console in the proxy configuration.

                   

                  Check out the above steps and let us know if this helps.

                   

                  Mike Tarallo

                  • Re: Re: Sense .NET API, QMC configurations needed?
                    Lars-Goran Book

                    If you are not running a desktop you should use :

                    ILocation myLocation = Qlik.Engine.Location.LocalServer;

                    if the qlik engine is running on the same machine or better would be to use


                    Uri uri = new Uri("http://<machine>:<port>");

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

                    where port should be 4747.

                      • Re: Sense .NET API, QMC configurations needed?
                        Markus Rytkölä

                        Thanks both Lars-Goran and Michael!

                         

                        I still can't get around this, if you say nothing should be pointing at 4848, and I have not specified any ports myself, my Proxy settings looks like Michaels.

                         

                        I did two tests, incorporated your advice.

                         

                        Test1)

                        ( Note! 4848 is NOT configured by my anywhere, netstat shows listening port as 4747)

                         

                         

                        ILocation myLocation = Qlik.Engine.Location.LocalServer;

                                using (IHub hub = myLocation.Hub())

                                {

                                    MessageBox.Show(hub.QvVersion());

                                }

                         

                         

                        Results in:

                        SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:4848    

                         

                         

                         

                         

                        Test2)

                         

                         

                           Uri uri = new Uri("http://win7devbox:4747");

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

                              //  ILocation myLocation = Qlik.Engine.Location.LocalServer;

                                using (IHub hub = myLocation.Hub())

                                {

                                    MessageBox.Show(hub.QvVersion());

                                }

                        Results in:

                        System.TimeoutException was thrown: "QlikConnection "Open" timed out"

                         

                         

                        So yes, it does seems like I cannot reach port 4747, but according to netstat it's listening.

                         

                        I haven't started to remove certificiates yet, BUT this is a clean 1.0GA install on a squeaky clean Win7 install.

                          • Re: Re: Sense .NET API, QMC configurations needed?

                            If the uri fails to resolve it will default to "ws://127.0.0.1:4848", the uri could fail to resolve if you are running with too low rights to see the Sense instance in the list of running processes or if the process is called something else than QlikSense or Engine.


                            one workaround would be to specify the Uri explicitly as you are doing, but then you also need specify explicitly the way to authenticate.


                            var location = Location.FromUri(uri);
                            location.AsNtlmUserViaProxy();
                            

                             

                            or

                             

                            var location = Location.FromUri(uri);
                            location.AsStaticHeaderUserViaProxy("<userId>");
                            
                    • Re: Sense .NET API, QMC configurations needed?

                      If you are accessing a remote server and have a local Qlik Sense installed you need to add your local computer to the "Websocket origin white list" in the remote QMC.

                       

                      Add your full computer name here:

                      QMC -> Proxies -> (Edit Proxy) -> Default proxy Properties -> Websocket origin white list

                       

                      The missing white-list entry should be visible in the server logs. it has to do with the Origin header sent to the server is defined as the computer running the code, not the server you are talking to.

                       

                      When you run Qlik Sense in a browser the code originates from the server and the Origin header is defined as the server. the server is automatically added to the white-list on installation.

                       

                      See https://help.qlik.com/sense/en-US/online/index.html#../Subsystems/Qlik_Management_Console_help/Content/QMC_Entity_QPS_De… for more information.