Skip to content

Commit 3b2178d

Browse files
committed
Merge pull request #560 from meteor/fix-ws-arg-order
Fix argument order for ws stream pass
2 parents 7a53ec2 + 0b223ab commit 3b2178d

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

Diff for: lib/http-proxy/passes/ws-incoming.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var passes = exports;
7878
*
7979
* @api private
8080
*/
81-
function stream(req, socket, options, server, head, clb) {
81+
function stream(req, socket, options, head, server, clb) {
8282
common.setupSocket(socket);
8383

8484
if (head && head.length) socket.unshift(head);

Diff for: test/lib-http-proxy-test.js

+22-2
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,29 @@ describe('lib/http-proxy.js', function() {
261261
});
262262
});
263263
});
264-
});
265264

266-
describe('#createProxyServer using the ws-incoming passes', function () {
265+
it('should emit error on proxy error', function (done) {
266+
var ports = { source: gen.port, proxy: gen.port };
267+
var proxy = httpProxy.createProxyServer({
268+
// note: we don't ever listen on this port
269+
target: 'ws://127.0.0.1:' + ports.source,
270+
ws: true
271+
}),
272+
proxyServer = proxy.listen(ports.proxy),
273+
client = new ws('ws://127.0.0.1:' + ports.proxy);
274+
275+
client.on('open', function () {
276+
client.send('hello there');
277+
});
278+
279+
proxy.on('error', function (err) {
280+
expect(err).to.be.an(Error);
281+
expect(err.code).to.be('ECONNREFUSED');
282+
proxyServer._server.close();
283+
done();
284+
});
285+
});
286+
267287
it('should proxy a socket.io stream', function (done) {
268288
var ports = { source: gen.port, proxy: gen.port };
269289
var proxy = httpProxy.createProxyServer({

0 commit comments

Comments
 (0)