diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/binance.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/binance.js b/lib/binance.js index 2f4f7ef7..151ce6a7 100644 --- a/lib/binance.js +++ b/lib/binance.js @@ -1,11 +1,21 @@ const WebSocket = require("ws"); module.exports = () => { + l.info("connecting to binance"); binance = new WebSocket( "wss://stream.binance.com:9443/ws/btcusdt@ticker" ); + binance.onopen = function(event) { + l.info("binance socket opened"); + }; + + binance.onerror = function(event) { + l.error("binance socket error", event); + }; + binance.onmessage = async function(event) { + l.info("got rates from binance"); try { let msg = JSON.parse(event.data); app.set("bid", msg.b); @@ -21,6 +31,7 @@ module.exports = () => { }); app.set("rates", rates); + l.info("saved binance rates"); } catch(e) { l.error("binance socket error", e); } |
