Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

.NetSdk - Connection failed after 4 attempts

Hi Guys,

we use .NetSDK to integrate QlikSense in an ERP - system. Now we are faced with following problem:

     We are not able to cache the Location or the Connection, so we have to connect us with the QlikSense Server several times. But      after these attempts an error occurs:

Exception NAVdiscovery.png

It also affects the hub. The user has no access.

2015-09-22 10_09_53-Qlik Sense.png

Do you have a solution for this issue?

(I reconstructed this with the engine API, but there is a similar problem. After several method calls I receive an errormessage, which includes the information, that the server has canceled the connection)

Thank you

René

1 Solution

Accepted Solutions
Not applicable
Author

Hi,
Lots of questions and confusions here, I will try sort this out.
There are three types of sessions :
Engine Session
Proxy Session
QlikConnection Session (.Net SDK)

The engine session is built up of user id and session id, you can use the .Net SDKs Session.WithApp(IAppIdentifier appIdentifier,

SessionType sessionType) to control the connect to the engine session. SessionType.Default is the same session as the clients session.
You can also create you own session ids or use the SessionType.Random.

The proxy session which is the connection to Qlik Sense instance (and affects the license user/token) and corresponds to a .Net SDK

Location. Your Location will tipically be created with "Location.FromUri". The location can be reused for many apps.
When the Location goes out of scope it will be disposed within the SDK but the liceense token will stil remain active for 30 minutes (this can be modified in the qmc).
If you wish to drop he license before 30 minutes you must do a Logout (REST call) to the proxy to drop that license token, more information

can be found in the Qlik Sense Proxy Service API under the help pages.

Best practice is to create one Qlik.Engine.Location and reuse this between different Qlik Sense applications. If you need more than one create as many as you need, but be aware of licenses.

Example:
try
{
  using (ILocation local = Qlik.Engine.Location.FromUri(new Uri("https://myserver.domain.com")))
  {
    local.AsNtlmUserViaProxy();

    foreach (var entry in local.GetAppIdentifiers())
    {
      try
      {
        using (var app = local.App(entry))
        {
          var reloadSucceded = app.DoReload();
   // do other work
        } // the engine session and .Net SDKs Session are disposed.
      }
      catch (Qlik.Engine.MethodInvocationException methodInvocationException)
      {
        // handle error
      }
    }
  } // using local, the license token will be released after 30 min.
}
catch (Qlik.Engine.Communication.CommunicationErrorException communicationException)
{
  // handle error
}

Best regard

Lars-Göran Book

View solution in original post

17 Replies
Anonymous
Not applicable
Author

I too have run into this issue. Everything was working fine until upgrading to Qlik Sense 2.1.1

Alexander_Thor
Employee
Employee

Hey,

Are you opening additional apps?
Each license is limited to 5 concurrent sessions so make sure you tidy up and close your sessions as you switch between apps.

Anonymous
Not applicable
Author

This is happening when attempting to get the first app:

var location = Location.FromUri(new Uri("ws://" + _hostName + ":4747"));

location.AsDirectConnection(_userDirectory, _userName);

var appId = location.AppWithId(app.Id);

The error occurs on the last line:

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

Not applicable
Author

Hey,

do you have a code example, which demonstrates how to close or delete the session with .NetSDK?

Thank you.

René

Not applicable
Author

Hi Randy,

it seems to be another topic.

Try to use http instead of ws and you should set "Allow HTTP" enabled in Proxy settings on QMC.

In my opinion the port isn't neccessary at all.

Another possibility is to try: location.AsNtlmUserViaProxy(proxyUsesSsl: useSsl)

With best regards,

René

Alexander_Thor
Employee
Employee

Well in this case port 4747 and direct connection would imply that you are bypassing the proxy and talk directly with the engine with root admin privileges.

ext_lgb‌ might have some samples for you and also more insight into the errors you are seeing on the topic in the post.

Not applicable
Author

Hi,

I haven't found a sample of ext_lgb matching my issue.

Not applicable
Author

Hi,

I do not change the app, the session token is always the same.

But I need every time a new location.

The error occurs when I call:

     location.AppWithNameOrCreate(appName);

There isn't a possibility in our scenario to catch the location, this seems to be a problem.

Not applicable
Author

Hi,
Lots of questions and confusions here, I will try sort this out.
There are three types of sessions :
Engine Session
Proxy Session
QlikConnection Session (.Net SDK)

The engine session is built up of user id and session id, you can use the .Net SDKs Session.WithApp(IAppIdentifier appIdentifier,

SessionType sessionType) to control the connect to the engine session. SessionType.Default is the same session as the clients session.
You can also create you own session ids or use the SessionType.Random.

The proxy session which is the connection to Qlik Sense instance (and affects the license user/token) and corresponds to a .Net SDK

Location. Your Location will tipically be created with "Location.FromUri". The location can be reused for many apps.
When the Location goes out of scope it will be disposed within the SDK but the liceense token will stil remain active for 30 minutes (this can be modified in the qmc).
If you wish to drop he license before 30 minutes you must do a Logout (REST call) to the proxy to drop that license token, more information

can be found in the Qlik Sense Proxy Service API under the help pages.

Best practice is to create one Qlik.Engine.Location and reuse this between different Qlik Sense applications. If you need more than one create as many as you need, but be aware of licenses.

Example:
try
{
  using (ILocation local = Qlik.Engine.Location.FromUri(new Uri("https://myserver.domain.com")))
  {
    local.AsNtlmUserViaProxy();

    foreach (var entry in local.GetAppIdentifiers())
    {
      try
      {
        using (var app = local.App(entry))
        {
          var reloadSucceded = app.DoReload();
   // do other work
        } // the engine session and .Net SDKs Session are disposed.
      }
      catch (Qlik.Engine.MethodInvocationException methodInvocationException)
      {
        // handle error
      }
    }
  } // using local, the license token will be released after 30 min.
}
catch (Qlik.Engine.Communication.CommunicationErrorException communicationException)
{
  // handle error
}

Best regard

Lars-Göran Book