websocket._exceptions.WebSocketProxyException: failed CONNECT via proxy status: 503
Asked Answered
P

1

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!

Piffle answered 8/2, 2019 at 5:58 Comment(14)
Your private key path has errorsCockiness
@MadPhysicist, Edited private key path in question. I'm getting same error. Please help!Piffle
I deleted the last line in your question because this is not FacebookCockiness
Now there's a stray space at the endCockiness
@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?Piffle
\\ is sufficient. It won't take the quote when it's doubled.Cockiness
still getting the same error :( . I'm worried about proxies. Did I configured in right syntactical way?Piffle
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?Slovakia
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?Piffle
@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.Xylo
Consider that the trailing space results in "\\ root.pem" instead of "\\root.pem" which is probably what you wanted...Rainger
@Myst, Removed the trailing space. Still getting the same error.Piffle
@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.Piffle
See https://mcmap.net/q/1159830/-dataframe-drop-rows-based-on-specific-conditions-of-columnsNonferrous
P
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.

Piffle answered 12/2, 2019 at 9:41 Comment(2)
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: 503Outsoar
@Sudhanvac Nope, I moved out of that project quite a long time back.Piffle

© 2022 - 2024 — McMap. All rights reserved.