Created
March 8, 2018 00:30
-
-
Save WietseWind/1016710c39ff512c645bf9affc512abe to your computer and use it in GitHub Desktop.
Rippled Websocket proxy to test reconnecting & health checking for https://www.npmjs.com/package/rippled-ws-client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WebSocket = require('ws') | |
const ws = new WebSocket('wss://s1.ripple.com') | |
const wss = new WebSocket.Server({ port: 8011 }) | |
wss.on('connection', function connection(c) { | |
let sendmessages = true | |
setTimeout(function () { | |
sendmessages = false | |
}, 20 * 1000) | |
c.on('message', function incoming(message) { | |
console.log('> %s', message) | |
if (sendmessages) ws.send(message) | |
}) | |
c.on('close', function closed(r) { | |
console.log('close', r) | |
}) | |
ws.on('message', function message(m) { | |
console.log('< %s', m) | |
c.send(m) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment