Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
master_t
Partner - Creator II
Partner - Creator II

.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?

10 Replies
Øystein_Kolsrud
Employee
Employee

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

david7gauthier
Contributor II
Contributor II

Hello,

I have exactly the same problem,

Any solution?

Thanks

Øystein_Kolsrud
Employee
Employee

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);
david7gauthier
Contributor II
Contributor II

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

Øystein_Kolsrud
Employee
Employee

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.

david7gauthier
Contributor II
Contributor II

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

Øystein_Kolsrud
Employee
Employee

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

david7gauthier
Contributor II
Contributor II

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)

 

 

Øystein_Kolsrud
Employee
Employee

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.