【发布时间】:2016-11-18 15:31:45
【问题描述】:
我已使用 Python 外部包 websocket-client 连接到发送事件的 RESTful 服务。
from websocket import create_connection
ws = create_connection("wss://machine:port/servicename/subscribe")
for event in ws:
print event
...getting events printed
我想知道是否可以使用核心 Python 2.7 或 Python 3.5 实现相同的功能,而无需安装外部 websocket-client 包或任何其他第 3 方 Python 包。
我已经搜索了互联网和那些我见过的使用 Python socket 模块的代码示例,参考通过http 或tcp 的连接,而我需要通过wss 建立连接。
【问题讨论】: