14 Replies Latest reply: Jan 22, 2016 5:24 AM by Lars-Goran Book RSS

    Connecting to Qlik sense Server using .NET SDK

    M. Abdulrahman Zia

      Hi,

      I am using qlik sense server version 2.1.1 and have .net sdk version also 2.1.1. I am trying to build a windows forms application which simply displays the server version. When I run the code, it gives me an error "unable to keep connection opened".

       

      I am attaching the screenshot of error and below is my code.

           

           private void Form1_Load(object sender, EventArgs e)

              {          

                  Uri uri = new Uri("https://abdullah-pc:4747");  // abdullah-pc is my server machine

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

                  location.AsNtlmUserViaProxy();

                

                  using (IHub hub = location.Hub())

                  {

                      label1.Text = hub.ProductVersion();

                  }

              }

       

      If anyone helps, I'll be thankful.

       

      AbdulRahman

        • Re: Connecting to Qlik sense Server using .NET SDK
          Øystein Kolsrud

          Do you use virtual proxies? You might have to do a proxy setting on the location object. Something like this:

           

          location.VirtualProxyPath = "myproxypath"

          • Re: Connecting to Qlik sense Server using .NET SDK
            Konrad Mattheis

            Hi Abdul,

             

            I think you use the wrong uri:

             

            just remove the :4747

            Uri uri = new Uri("https://abdullah-pc/);  // abdullah-pc is my server machine

             

            bye

            Konrad

              • Re: Connecting to Qlik sense Server using .NET SDK
                M. Abdulrahman Zia

                Hello Konard,

                 

                I have tried that all things. like  ws://localhost:4848,  https://abdullah-pc:4244, https://localhost:4848, https://abdullah-pc.  But same error popping out


                AbdulRahman

                  • Re: Connecting to Qlik sense Server using .NET SDK
                    Konrad Mattheis

                    Hi Abdul,

                     

                    it should work. I do the same with no problems. Please go through that checklist:

                    1. Qlik Sense Server on your PC Version 2.1.1

                    2. If you open Qlik Sense in "Internet Explorer" you can connect without any ssl error

                    3. please try just:

                           using (var db= new DebugConsole())

                                {

                     

                               location = Qlik.Engine.Location.FromUri(new URI("https://abdullah-pc"));

                              location.AsNtlmUserViaProxy(ssl);

                           using (IHub hub = location.Hub())

                                {

                                    label1.Text = hub.ProductVersion();

                                }

                         }

                    Please also add Screenshots and the output in the Console.

                     

                    thx Konrad

                      • Re: Connecting to Qlik sense Server using .NET SDK
                        M. Abdulrahman Zia

                        Thanks Konard for your help. I am able to open qlik sense in IE 11. Also I have used DebugConsole() function and got a complete error trace. Attaching the text file of error description.

                        • Re: Connecting to Qlik sense Server using .NET SDK
                          M. Abdulrahman Zia

                          Sorry Konard,

                          I was unable to attach file. I am writing here the error log from console. ! !

                           

                           

                          ### WebSocket Error: Object reference not set to an instance of an object. ### 43927528

                          ### WebSocket Stack Trace: 43927528

                             at Qlik.Sense.Communication.Communication.Tcp.StreamFactory.NegotiateAsClient(ITcpClientWrapper tcpClient, Uri remoteUri, SslConnection sslConnection, Action`1 onComplete, Action`1 onError)

                             at Qlik.Sense.Communication.Communication.WebSocketProtocol.WebSocketHandler.<>c__DisplayClass6.<NewClientWebSocketAsync>b__4(ITcpClientWrapper client)

                             at Qlik.Sense.Communication.Communication.Tcp.TcpClientWrapperFactory`1.<>c__DisplayClass5.<NewAndConnectedTcpClient>b__4(IAsyncResult result)

                          ### Failed to ensure open connection ### 43927528

                          ### Failed attempt 1 ### 43927528

                          ### Failure message: Failed to ensure open connection: One or more errors occurred.

                          ### WebSocket Error: Object reference not set to an instance of an object. ### 43927528

                          ### WebSocket Stack Trace: 43927528

                             at Qlik.Sense.Communication.Communication.Tcp.StreamFactory.NegotiateAsClient(ITcpClientWrapper tcpClient, Uri remoteUri, SslConnection sslConnection, Action`1 onComplete, Action`1 onError)

                             at Qlik.Sense.Communication.Communication.WebSocketProtocol.WebSocketHandler.<>c__DisplayClass6.<NewClientWebSocketAsync>b__4(ITcpClientWrapper client)

                             at Qlik.Sense.Communication.Communication.Tcp.TcpClientWrapperFactory`1.<>c__DisplayClass5.<NewAndConnectedTcpClient>b__4(IAsyncResult result)

                          ### Failed to ensure open connection ### 43927528

                          ### Failed attempt 2 ### 43927528

                          ### Failure message: Failed to ensure open connection: One or more errors occurred.

                          ### WebSocket Error: Object reference not set to an instance of an object. ### 43927528

                          ### WebSocket Stack Trace: 43927528

                             at Qlik.Sense.Communication.Communication.Tcp.StreamFactory.NegotiateAsClient(ITcpClientWrapper tcpClient, Uri remoteUri, SslConnection sslConnection, Action`1 onComplete, Action`1 onError)

                             at Qlik.Sense.Communication.Communication.WebSocketProtocol.WebSocketHandler.<>c__DisplayClass6.<NewClientWebSocketAsync>b__4(ITcpClientWrapper client)

                             at Qlik.Sense.Communication.Communication.Tcp.TcpClientWrapperFactory`1.<>c__DisplayClass5.<NewAndConnectedTcpClient>b__4(IAsyncResult result)

                          ### Failed to ensure open connection ### 43927528

                          ### Failed attempt 3 ### 43927528

                          ### Failure message: Failed to ensure open connection: One or more errors occurred.

                          ### WebSocket Error: Object reference not set to an instance of an object. ### 43927528

                          ### WebSocket Stack Trace: 43927528

                             at Qlik.Sense.Communication.Communication.Tcp.StreamFactory.NegotiateAsClient(ITcpClientWrapper tcpA first chance exception of type 'Qlik.Engine.Communication.CommunicationErrorException' occurred in Qlik.Engine.dll

                          Client, Uri remoteUri, SslConnection sslConnection, Action`1 onComplete, Action`1 onError)

                             at Qlik.Sense.Communication.Communication.WebSocketProtocol.WebSocketHandler.<>c__DisplayClass6.<NewClientWebSocketAsync>b__4(ITcpClientWrapper client)

                             at Qlik.Sense.Communication.Communication.Tcp.TcpClientWrapperFactory`1.<>c__DisplayClass5.<NewAndConnectedTcpClient>b__4(IAsyncResult result)

                          ### Failed to ensure open connection ### 43927528

                          ### WebSocket Error: Connection failed after 4 attempts. Unable to keep connection open: Failed to ensure open connection: One or more errors occurred. ### 43927528

                    • Re: Connecting to Qlik sense Server using .NET SDK
                      Lars-Goran Book

                      Hi,

                      are you running with the proxy? If so have you configured "Websocket origin white list" in your qmc (see Virtual proxies - Advanced), you can add your ip-adress or your domain (for example qlik.com).

                      It could also be issues with your certificate configuration, you can test to allow HTTP (see Proxies - Ports),

                      in this case you should use http://abdullah-pc

                       

                      Best Regards

                      Lars-Göran Book

                      • Re: Connecting to Qlik sense Server using .NET SDK
                        Mohamed ROUS

                        hello

                         

                        Try to use  location.AsNtlmUserViaProxy(proxyUsesSsl: true) (change your proxyUsesSsl to true.


                        Best regards  

                        • Re: Connecting to Qlik sense Server using .NET SDK
                          Lars-Goran Book

                          Hi,

                          I can see that you are using the port for the engine but when connecting you going to the proxy.

                          There should not be any port in the uri when connecting thru the proxy i.e.

                          Uri uri = new Uri("https://abdullah-pc");

                           

                          Best Regards

                          Lars-Göran Book