Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Partner
Partner

.NET SDK - Sharing session

Hi

I'm trying to share a session between a browser and and the .NET SDK, so that selections are mirrored on both ends. I'm connetcing to a QlikSense server using a certificate, and o like this:

//Connect to QlikSense server

senseLocation.AsDirectConnection(

    "myuserdir", //User directory

    "administrator", //UserID (this user is RootAdmin)

    false,

    false,

    x509coll //Certificate

);

var appIdentifier = ...

var senseSession = Session.WithApp(appIdentifier, SessionType.Default);

var appInstance = senseLocation.App(appIdentifier, senseSession);

then I'm applying some selections:

app.GetField("Foo").Select("Bar");

however, the selection does not get applyed on the broser side. And likewise, if I apply some selections using the browser they are not applied when querying data via the SDK.

EDIT: more precisely: sometimes nothing happens, other times the last lines causes this error on the client session:

2018-04-16 14_48_38-TEST _ Fogli - Qlik Sense.png

Which translates more or less to:

An error occurred

Connection to the QlikSense engine failed due to unspecified reasons

Refresh your browser or contact a system administrator


What am I missing here?

Tags (1)
10 Replies
Highlighted
Employee
Employee

Re: .NET SDK - Sharing session

Hi! FYI: There's another thread on a similar topic here: Re: Net SDK session shared with client

Highlighted
Contributor II
Contributor II

Re: .NET SDK - Sharing session

Hello,

I have exactly the same problem,

Any solution?

Thanks

Highlighted
Employee
Employee

Re: .NET SDK - Sharing session

This might not solve your problem, but it seems that you get the behavior you are looking for if you connect using NTLM through the proxy. So this configuration should make your SDK selections visible in the client:

senseLocation.AsNtlmUserViaProxy();
var appIdentifier = ...
var senseSession = Session.WithApp(appIdentifier, SessionType.Default);
var appInstance = senseLocation.App(appIdentifier, senseSession);
Highlighted
Contributor II
Contributor II

Re: .NET SDK - Sharing session

Thank you for your response.

But i have a time out error.

please see the attached image 

2018-12-25 13_04_00-Microsoft Visual Studio.png

 

the server is like this: "http://my-server.home.local:4747"

 

Thanks

Highlighted
Employee
Employee

Re: .NET SDK - Sharing session

You shouldn't include the port number if you want to go through the proxy. By adding the port 4747 you are directing the traffic directly to the engine instead.

Highlighted
Contributor II
Contributor II

Re: .NET SDK - Sharing session

Thank you so much

It works very well !!!

But, do you know why we cannot connect with AsDirectConnection() with a certificate?

My code is like this:

Capture.PNG

the server is like this: "http://my-server.home.local:4747"

I have not error of compilation neither execution:

But I cannot connect to the Engine.

Capture2.PNG

 

Thanks

Highlighted
Employee
Employee

Re: .NET SDK - Sharing session

Have you checked your firewall settings? Perhaps the port is blocked?

Highlighted
Contributor II
Contributor II

Re: .NET SDK - Sharing session

Thank you again for your response.

To be sure that the port 4747 is Open, i turned off the firewall.

As you can see in the image bellow the port 4747 is open on my server

4747-port-open.png

And I retried to connect from the server where Qlik Sense is installed (without certification) using the code bellow , but I have steel the same error:

private IApp ConnectWithDirectConnection(string server, string qlikSenseAppId)
{
IApp app = null;

var uri = new Uri(server);
ILocation location = Qlik.Engine.Location.FromUri(uri);
// Defining the location as a direct connection to Qlik Sense Server
location.AsDirectConnection(Environment.UserDomainName, Environment.UserName);
location.IsVersionCheckActive = false;

IAppIdentifier appId = location.AppWithIdOrDefault(qlikSenseAppId);
ISession session = Session.WithApp(appId, SessionType.Default);
IHub hub = LocationExtensions.Hub(location, session);
app = hub.OpenApp(appId.AppId);

app.GetField("Region").Select("Africa");
return app;
}

When I do not use 'session' ==> "IHub hub = LocationExtensions.Hub(location);" I do not have the error but when I make selections nothing happens in the application (app.GetField("Region").Select("Africa"); ==> no effect in UI)

 

 

Highlighted
Employee
Employee

Re: .NET SDK - Sharing session

I did some more research on this, and it looks like the system actively blocks you from connecting to a client session when you are using direct connection to the engine. It seems like there is some security mechanism in place that prevents it. If you try to access an active client session using direct connection, then the client will receive these messages on its web socket:

{"jsonrpc":"2.0","method":"OnClosed","params":{"qSessionState":"SESSION_ERROR_SECURITY_HEADER_CHANGED"}}
{"jsonrpc":"2.0","method":"OnEngineWebsocketFailed","params":{"severity":"fatal","timestamp":"2019-03-28T13:55:10.9758005Z","message":"Connection to Qlik service failed, shutting down"}}

And you probably want to go through the proxy anyway when you connect to the client session as in a multi node system, you typically don't know which engine node the client session ends up on.