qlik-oss / enigma.js

JavaScript library for consuming Qlik's Associative Engine.
MIT License
209 stars 82 forks source link

Enigma js connection failed in new chrome browser #800

Closed hshahul closed 4 years ago

hshahul commented 4 years ago

Hi Team,

I am getting socket closed error in new chrome browser, but it is working fine in new Edge browser. Have any latest update from enigma js side, please let me know.

Sample code: const enigma = require('enigma.js'); const WebSocket = require('ws'); const schema = require('enigma.js/schemas/12.170.2.json');

// create a new session: const session = enigma.create({ schema, url: 'ws://localhost:9076/app/engineData', createSocket: url => new WebSocket(url), });

// bind traffic events to log what is sent and received on the socket: session.on('traffic:sent', data => console.log('sent:', data)); session.on('traffic:received', data => console.log('received:', data));

// open the socket and eventually receive the QIX global API, and then close // the session: session.open() .then((/global/) => console.log('We are connected!')) .then(() => session.close()) .then(() => console.log('Session closed')) .catch(err => console.log('Something went wrong :(', err));

Error: code: -1 message: "Socket closed" proto: Object

I tried latest schema json also, but no luck.. have any new changes for chrome browser

axelssonHakan commented 4 years ago

I just verified that it's working in Chrome 85: Web app: https://79yqi.csb.app/ Code: https://codesandbox.io/s/keen-galois-79yqi

axelssonHakan commented 4 years ago

If you are using QlikCloud the URL would be in the format: wss://<tenantName>.<region>.qlikcloud.com/app/<appId>?qlik-web-integration-id=<webIntegrationId>

Enigma.js doesn't provide any login. Verify that there is a session Cookie created to be able to connect and also that the web-integrtionId is set and configured correctly. The cookie will expire and you could experience that something that just worked minutes before has stopped working, but you should see a 403 in the network trace in that case

https://github.com/qlik-oss/web-integration-examples

axelssonHakan commented 4 years ago

@hshahul any update on this? Could you confirm that you are using qlikcloud when you say web url API (ref #795)

hshahul commented 4 years ago

I tried web api url only but not working chrome browser. that same code is working in Edge browser. ( Previously that same code worked in chrome and Edge browser too). Recently it is happed, no code change.

Have any setting need to change?

axelssonHakan commented 4 years ago

It's not clear what you mean when you say "web api url", what product are you connecting to:

axelssonHakan commented 4 years ago

@hshahul the different deployments/products has some different requirements for connecting the WebSocket. Qlik Core / Qlik Sense desktop doesn't have any authentication Qlik Sense Enterprise on Windows requires cert/JWT/ticket and xrfkey Qlik Sense Cloud requires cookie and qlik-web-integration-id + qlik-csrf-token

To help you we need to know what deployments/products you are using

axelssonHakan commented 4 years ago

Closed due to inactivity

dselgo commented 4 years ago

Hello, I am also experiencing this issue. About a month or two ago my team started reporting that they weren't able to form a websocket connection to Qlik Sense using enigma.js. This issue only occurs on Chrome (Edge works fine) and only occurs when running on localhost (I tested and our production site is still able to connect with Chrome).

The socket closes immediately and gives this message:

{"jsonrpc":"2.0","method":"OnAuthenticationInformation","params":{"mustAuthenticate":true}}

I can confirm that we are sending an Authentication Header containing the JWT. Like I said it was working a few months ago and we haven't changed anything in our connection configuration, and it is still working in Edge so I don't believe that it is a problem on my end.

We are using Qlik Sense Enterprise on Windows and authenticating via JWT. Please let me know if there is any more information you need and I will try to provide it.

axelssonHakan commented 4 years ago

Could you verify that the SameSite attribute is configured in the QMC: https://community.qlik.com/t5/Support-Knowledge-Base/Qlik-Sense-Missing-SameSite-attribute-now-blocks-requests-in/ta-p/1712551?_ga=2.129113356.1253695434.1598801040-1104108221.1556901968

dselgo commented 4 years ago

Could you verify that the SameSite attribute is configured in the QMC: https://community.qlik.com/t5/Support-Knowledge-Base/Qlik-Sense-Missing-SameSite-attribute-now-blocks-requests-in/ta-p/1712551?_ga=2.129113356.1253695434.1598801040-1104108221.1556901968

It is not because we are still on the February 2020 release. We are planning on upgrading in a few weeks. I did confirm that this is causing the issue for me by setting the Chrome flags for same site cookies to disabled. Once we upgrade Qlik Sense, I'll be sure to adjust the proxy service. Thank you @axelssonHakan for providing insight into this!

hshahul commented 4 years ago

Thanks for the update. It's working now.

Really thank you so much

On Tue, 29 Sep, 2020, 9:02 pm dselgo, notifications@github.com wrote:

Could you verify that the SameSite attribute is configured in the QMC:

https://community.qlik.com/t5/Support-Knowledge-Base/Qlik-Sense-Missing-SameSite-attribute-now-blocks-requests-in/ta-p/1712551?_ga=2.129113356.1253695434.1598801040-1104108221.1556901968

It is not because we are still on the February 2020 release. We are planning on upgrading in a few weeks. I did confirm that this is causing the issue for me by setting the Chrome flags for same site cookies to disabled. Once we upgrade Qlik Sense, I'll be sure to adjust the proxy service. Thank you @axelssonHakan https://github.com/axelssonHakan for providing insight into this!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/qlik-oss/enigma.js/issues/800#issuecomment-700954791, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNLMPKLUEZIK7MSEYWN25DSII4PDANCNFSM4RRZSFQQ .