linux websocket 400错误,无法连接到Binance websocket。我得到:WebSocketBadStatusException:握手状态400错误请求...

您可以安装python binance并使用BinanceSocketManager

python-m pip安装python二进制文件

使用我找到的以下代码

here

import time

from binance.client import Client # Import the Binance Client

from binance.websockets import BinanceSocketManager # Import the Binance Socket Manager

# Although fine for tutorial purposes, your API Keys should never be placed directly in the script like below.

# You should use a config file (cfg or yaml) to store them and reference when needed.

PUBLIC = ''

SECRET = ''

# Instantiate a Client

client = Client(api_key=PUBLIC, api_secret=SECRET)

# Instantiate a BinanceSocketManager, passing in the client that you instantiated

bm = BinanceSocketManager(client)

# This is our callback function. For now, it just prints messages as they come.

def handle_message(msg):

print(msg)

# Start trade socket with 'ETHBTC' and use handle_message to.. handle the message.

conn_key = bm.start_trade_socket('ETHBTC', handle_message)

# then start the socket manager

bm.start()

# let some data flow..

time.sleep(10)

# stop the socket manager

bm.stop_socket(conn_key)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值