$ rlwrap websocat wss://ws-feed.gdax.com
# Now enter this line (without the #) for the required JSON request:
# {"type":"subscribe","channels": [{ "name": "heartbeat", "product_ids": ["BTC-USD"] }]}
{"type":"subscriptions","channels":[{"name":"heartbeat","product_ids":["BTC-USD"]}]}
{"type":"heartbeat","last_trade_id":46274575,"product_id":"BTC-USD","sequence":6312079752,"time":"2018-07-12T22:32:42.655000Z"}
{"type":"heartbeat","last_trade_id":46274575,"product_id":"BTC-USD","sequence":6312079800,"time":"2018-07-12T22:32:43.656000Z"}
{"type":"heartbeat","last_trade_id":46274575,"product_id":"BTC-USD","sequence":6312079834,"time":"2018-07-12T22:32:44.656000Z"}
{"type":"heartbeat","last_trade_id":46274575,"product_id":"BTC-USD","sequence":6312079945,"time":"2018-07-12T22:32:45.656000Z"}
{"type":"heartbeat","last_trade_id":46274575,"product_id":"BTC-USD","sequence":6312079990,"time":"2018-07-12T22:32:46.657000Z"}
{"type":"heartbeat","last_trade_id":46274575,"product_id":"BTC-USD","sequence":6312080042,"time":"2018-07-12T22:32:47.657000Z"}
{"type":"heartbeat","last_trade_id":46274576,"product_id":"BTC-USD","sequence":6312080169,"time":"2018-07-12T22:32:48.657000Z"}
# To stop the feed, type this line:
{"type":"unsubscribe","channels": [{ "name": "heartbeat", "product_ids": ["BTC-USD"] }]}
{"type":"subscriptions","channels":[]}
5条答案
按热度按时间2ic8powd1#
假设您已经安装了
node
,我会给予一下wscat
;它"简单“、”直观“、”强大“,除此之外,@Pavel的答案还有很多值得尊敬的WebSocket客户端替代品。xriantvc2#
那么,您可以尝试使用curl来模拟所需的头文件以获得一些响应:
此外,还有其他方式与WebSocket服务器通信,例如:
qni6mghb3#
我想为此添加我自己的工具:websocat.
与相关服务的会话示例:
除了websocket客户端,websocat还支持WebSocket服务器和其他模式,旨在将websocket集成到"UNIX"世界中。
wpcxdonn4#
ws
通过http
协议启动连接,您必须将ws
更改为http
和一些额外的头,如下所示:https://gist.github.com/htp/fbce19069187ec1cc486b594104f01d0
vdzxcuhz5#
您也可以使用Telnet连接到服务器
连接后,您可以以Json格式发送请求
此处6870是端口port,要打开端口,您需要运行
要检查pm2日志,您需要使用以下命令
希望这能帮上忙。