python-3.x - ValueError:方案 https 在 websocket 客户端打招呼中无效
问题描述
我遇到了与这个问题websockets "scheme https is invalid" 类似的问题,但我实际上是在尝试使用 https 问题是我收到了连接指令以从服务器获取数据,并且在该文档中,他给了我列表要连接的服务器。不幸的是,它是https://theirserverurl.com的列表,而不是像往常一样的 wss://。我试图通过以下方式向其中一台服务器打招呼:
from websocket import create_connection
ws = create_connection("https://theirserverurl.com")
print ("Sending 'Hello, World'...")
ws.send("Hello, World")
print ("Sent")
print ("Reeiving...")
result = ws.recv()
print ("Received '%s'" % result)
ws.close()
我得到的错误是:
ValueError: scheme https is invalid
有什么解决方案可以在 python 上克服这个堆栈。请帮助我。谢谢!
解决方案
您的网址不正确。您应该像这样输入 WSS URL:
wss://live-ws-pg-group3.kuaishou.com/websocket
推荐阅读
- typescript - 基于回调推断嵌套函数的typeof
- snakemake - 如何在不使用 cd 的情况下更改 Snakemake 中的输出目录
- ios - Swift:如何在标签中显示 Int?
- c# - 如何使用 MVC MapRoute 匹配与路径无关的文件扩展名?
- r - 为什么 R lubridate::duration 数据类型使用 sparklyr 转换为 spark 中的字符?
- javascript - 如何在 Vue.js 3 中使用 Vue 3 Meta?
- c++ - 函数无法随机检测事件
- python - 当我使用 crontab 在启动时运行 python 文件时,出现以下错误
- python - 安装 Keras:解决环境 - 失败
- javascript - React navigation 5 - 如何概括导航?