Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Connecting to Qlik sense Server using .NET SDK

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

14 Replies
Øystein_Kolsrud
Employee
Employee

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

location.VirtualProxyPath = "myproxypath"

Not applicable
Author

Hi Kolsrud,

Thanks for your quick reply. Actually I have installed sense server locally on my laptop. And I haven't configured any virtual proxy in it. but default virtual proxy set to Central is already setup. Attaching the screenshot.

One thing more, I use to give username, password each time when want to access qmc or hub. Also attaching the screenshot of that. may be it could be helpful resolving my issue. Also, I have added my machine name "Abdullah-PC"  to web socket whitelist in virtual proxy.

Thanks

konrad_mattheis
Luminary Alumni
Luminary Alumni

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

Not applicable
Author

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

konrad_mattheis
Luminary Alumni
Luminary Alumni

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

Not applicable
Author

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.

Not applicable
Author

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

Øystein_Kolsrud
Employee
Employee

Sounds like your Qlik Sense server is not set configured to utilize your windows credentials. You might want to look into the settings your QMC. For instance, have a look at the "User Directory Connectors" under "Manage Resources" and check that the relevant user directory is included there.

Øystein_Kolsrud
Employee
Employee

Since your server is running locally, it could also be possible for you to do a direct connection to it. So instead of doing "AsNtlmUserViaProxy" you would do "AsDirectConnection" like this:

location.AsDirectConnection(<your user directory name>, <your user id>);

But if you want to be able to use your application so that it can connect to non-local servers, then this is probably not your long term solution.