websocket._exceptions.WebSocketProxyException:通过代理状态的连接失败:503

时间:2019-02-08 05:58:23

标签: python python-3.x websocket http-proxy qliksense

提供的答案需要有关使用qlik服务器进行身份验证的更多详细信息

我正在尝试使用证书通过WebSockets连接到qlik

错误:

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

代码:

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()

*注意:

  • 我的网络有一个代理。
  • 我在sensehost, userDirectory, userId之类的每个字段中都使用了正确的值

请帮助或任何建议,感谢您连接qlik。

最终目标:要动态地将django开发的Qlik KPI值/图表放到前端!

1 个答案:

答案 0 :(得分:0)

部分答案:

根据Qlik .net SDK documentation,他们说Port: With proxy (443), without proxy (4747) or without security (80).

因此,我将url = "wss://" + senseHost + ":4747/app/"更改为url = "wss://" + senseHost + ":443/app/"

待处理

无法使用证书登录。我想使用NTLM身份验证。如何通过python将NTLM身份验证传递给websocket链接。

如果您有可以同时解决这两个问题的解决方案,请编辑或编写新答案。