Saya ingin menambahkan alat saya sendiri untuk ini:websocat.
Contoh sesi dengan layanan yang dimaksud:
$ 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":[]}
Selain klien websocket, websocat mendukung server WebSocket dan mode lainnya dan ditujukan untuk mengintegrasikan websockets ke dunia "UNIX" secara umum.
Nah, Anda dapat mencoba meniru tajuk yang diperlukan untuk mendapatkan respons menggunakan curl:
- https://gist.github.com/htp/fbce19069187ec1cc486b594104f01d0 atau
- Linux Bash:Cara membuka koneksi websocket sebagai klien
Selain itu, ada cara lain untuk berkomunikasi dengan server WebSocket, mis.
- https://github.com/websockets/wscat
- https://github.com/bwasti/webpipe
- https://github.com/progrium/wssh
Dengan asumsi Anda memiliki node
diinstal, saya akan memberikan wscat
tembakan; itu sederhana , intuitif , dan kuat . Jika tidak, jawaban @Pavel memiliki banyak sekali alternatif klien websocket terhormat.
# install
npm install -g wscat
# use
wscat -c "wss://ws-feed.gdax.com"
cara mencari direktori dari terminal di ubuntu
Laravel + SQLite =SQLSTATE[HY000]Kesalahan Umum:8 mencoba menulis database hanya-baca