用Python连接AWX-Websocket

2024-04-25 18:58:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图用这个文档(https://github.com/ansible/awx/blob/devel/docs/websockets.md#protocol)将我的Python应用程序连接到awxwebsocket。在这里撞到砖墙。感谢您的帮助。非常感谢。你知道吗

我可以通过将Python应用程序指向wss://my-awx.com/websocket从websocket接收http101响应,但在尝试订阅作业时,我既没有收到accept: true也没有收到accept: false。你知道吗

我的工作流程如下。首先我从/api/v2/tokens/收到一个令牌,然后我使用这个headers = { 'Authorization': 'Bearer' + auth_token }并在创建连接时将其用作头的一部分。至少这是我从这个文档(https://github.com/ansible/awx/blob/devel/docs/websockets.md#protocol)收集到的信息

You must provide a valid Auth Token in the request URL.

这是我的Python应用程序

--- request header ---
GET /websocket HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: my-awx.com
Origin: http://my-awx.com
Sec-WebSocket-Key: abcdefghijklmnopqwstuvwxyz
Sec-WebSocket-Version: 13
Authorization: Bearer abcdefghijklmnopqwstuvwxyz 

-----------------------
--- response header ---
HTTP/1.1 101 Switching Protocols
Server: openresty/1.15.8.1
Date: Thu, 19 Dec 2019 17:24:28 GMT
Connection: upgrade
Upgrade: WebSocket
Sec-WebSocket-Accept: abcdefghijklmnopqwstuvwxyz
Strict-Transport-Security: max-age=15724800; includeSubDomains
-----------------------

Tags: 文档httpsgithubcom应用程序mydevelsec