websocket proxy not work in node.js version 0.10.0
Created by: llevkin
a simple test:
var util = require('util'), http = require('http'), httpProxy = require('http-proxy');
try { var io = require('socket.io'), client = require('socket.io-client'); } catch (ex) { console.error('Socket.io is required for this example:'); process.exit(1); }
// // Create the target HTTP server and setup // socket.io on it. // var server = io.listen(8080); server.set('transports', ['websocket']); server.sockets.on('connection', function (client) { util.debug('Got websocket connection');
client.on('message', function (msg) { util.debug('Got message from client: ' + msg); }); client.send('from server'); });
// // Create a proxy server with node-http-proxy // httpProxy.createServer(8080, 'localhost').listen(8081);
// // Setup the socket.io client against our proxy // var ws = client.connect('ws://localhost:8081');
ws.on('message', function (msg) { util.debug('Got message: ' + msg); });
in node.js version 0.10.0 we are never got a message 'Got message: from server'.. In ver. 0.8.18 all work fine..