11

Provided answer need some more details regarding authentication with qlik server

I'm trying to connect to qlik using certificates through WebSockets.

Error:

websocket._exceptions.WebSocketProxyException: failed CONNECT via proxy status: 503

Code:

from websocket import create_connection  
import ssl  


senseHost = "dummy.xyz.com"  
privateKeyPath = "C:\\ProgramData\\Qlik\\Sense\\Repository\\Exported Certificates\\"  


## userDirectory and userId can be found at QMC -> Users  
userDirectory, userId = "DIRECTORY_OF_SERVER","QlikServerUserId"  


url = "wss://" + senseHost + ":4747/app/"  # valid  
certs = ({"ca_certs": privateKeyPath + "root.pem",  
            "certfile": privateKeyPath + "client.pem",  
            "keyfile": privateKeyPath + "client_key.pem",  
            "cert_reqs":ssl.CERT_REQUIRED,  
            "server_side": False  
            })  
ssl.match_hostname = lambda cert, hostname: True  
ws = create_connection(url, sslopt=certs,
                       http_proxy_host="xyz.corp.company.com",
                       http_proxy_port="80",
                       http_no_proxy="*.corp.company.com;*.abc.com;*.pqr.com;"
                       header={'X-Qlik-User: UserDirectory=%s; UserId=%s'% (userDirectory, userId)})  
session = self.ws.recv()

*Note:

  • My network has a proxy.
  • I have used the right values in every field like sensehost, userDirectory, userId

Please help or any suggestions can be appreciated to connect qlik.

Final aim: To get Qlik KPI values/charts into fronted developed by django dynamically!

shaik moeed
  • 5,300
  • 1
  • 18
  • 54
  • 1
    Your private key path has errors – Mad Physicist Feb 11 '19 at 04:54
  • @MadPhysicist, Edited private key path in question. I'm getting same error. Please help! – shaik moeed Feb 11 '19 at 04:56
  • I deleted the last line in your question because this is not Facebook – Mad Physicist Feb 11 '19 at 04:56
  • 1
    Now there's a stray space at the end – Mad Physicist Feb 11 '19 at 04:57
  • @MadPhysicist, yes, as ` \ ` consider for special character. It's not taking `"` if I didn't use space. Can you tell is there any other way for that escape character? – shaik moeed Feb 11 '19 at 04:59
  • `\\ ` is sufficient. It won't take the quote when it's doubled. – Mad Physicist Feb 11 '19 at 05:01
  • still getting the same error :( . I'm worried about proxies. Did I configured in right syntactical way? – shaik moeed Feb 11 '19 at 05:03
  • I had similar error in past. Seems like your URL is not white-listed . Are you trying to do it from home network of office network? – Puneet Sinha Feb 11 '19 at 05:23
  • I'm trying to do from office network and using office proxy settings. Did you solved the issue? Can you please tell what to do? – shaik moeed Feb 11 '19 at 05:32
  • @shaikmoeed Try the program from outside of the proxy if possible. The proxy introduces too many variables into the operation of the program and makes it really hard to debug without information regarding the proxy and how it operates, how it's configured, what it's intended to do, etc. – nhubbard Feb 11 '19 at 14:14
  • Consider that the trailing space results in `"\\ root.pem"` instead of "\\root.pem" which is probably what you wanted... – Myst Feb 11 '19 at 21:30
  • @Myst, Removed the trailing space. Still getting the same error. – shaik moeed Feb 12 '19 at 05:04
  • @nhubbard, Yes, it's really hard to debug and I don't have good understanding of proxies. What I did is just pasted all the proxy information from my computer settings`(which is present in manual proxy setup)`. If I used outside of the proxy I'm getting `websocket._exceptions.WebSocketAddressException: [Errno 11001] getaddrinfo failed` error. – shaik moeed Feb 12 '19 at 05:12
  • See https://stackoverflow.com/a/56906588/2336654 – piRSquared Jul 05 '19 at 16:37

1 Answers1

1

Partial Answer:

According to Qlik .net SDK documentation, they said Port: With proxy (443), without proxy (4747) or without security (80).

So, I changed url = "wss://" + senseHost + ":4747/app/" to url = "wss://" + senseHost + ":443/app/"

Pending:

Not able to login by using certificates. I want to use NTLM authentication. How to pass NTLM authentication to websocket link in python.

Please edit or write a new answer, if you are having a solution which can solve both issues.

shaik moeed
  • 5,300
  • 1
  • 18
  • 54
  • were you able to root cause the issue? Even I'm struck with the same error while creating websocket connection. websocket._exceptions.WebSocketProxyException: failed CONNECT via proxy status: 503 – Sudhanva c Nov 21 '22 at 06:20
  • @Sudhanvac Nope, I moved out of that project quite a long time back. – shaik moeed Nov 21 '22 at 12:06