Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • N node-http-proxy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 482
    • Issues 482
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 102
    • Merge requests 102
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • http ... PARTY!
  • node-http-proxy
  • Merge requests
  • !561

Close outgoing socket (fixes #559)

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/meteor/close-outgoing-socket into master 11 years ago
  • Overview 7
  • Commits 2
  • Pipelines 0
  • Changes 2

Created by: glasser

Note that this includes #560.

Compare
  • master (base)

and
  • latest version
    d8ea6879
    2 commits, 2 years ago

2 files
+ 32
- 6

    Preferences

    File browser
    Compare changes
lib/http-p‎roxy/passes‎
ws-inco‎ming.js‎ +10 -4
te‎st‎
lib-http-pr‎oxy-test.js‎ +22 -2
lib/http-proxy/passes/ws-incoming.js
+ 10
- 4
  • View file @ d8ea6879


@@ -78,7 +78,7 @@ var passes = exports;
*
* @api private
*/
function stream(req, socket, options, server, head, clb) {
function stream(req, socket, options, head, server, clb) {
common.setupSocket(socket);
if (head && head.length) socket.unshift(head);
@@ -88,10 +88,16 @@ var passes = exports;
common.setupOutgoing(options.ssl || {}, options, req)
);
// Error Handler
proxyReq.on('error', onError);
proxyReq.on('error', onOutgoingError);
proxyReq.on('upgrade', function(proxyRes, proxySocket, proxyHead) {
proxySocket.on('error', onError);
proxySocket.on('error', onOutgoingError);
// The pipe below will end proxySocket if socket closes cleanly, but not
// if it errors (eg, vanishes from the net and starts returning
// EHOSTUNREACH). We need to do that explicitly.
socket.on('error', function () {
proxySocket.end();
    • Administrator
      Administrator @root · 11 years ago
      Author Contributor

      Created by: jcrugzz

      We should also call onOutgoingError here since ending the proxySocket won't trigger its error event in anyway.

      • Please register or sign in to reply
Please register or sign in to reply
});
common.setupSocket(proxySocket);
@@ -106,7 +112,7 @@ var passes = exports;
return proxyReq.end(); // XXX: CHECK IF THIS IS THIS CORRECT
function onError(err) {
function onOutgoingError(err) {
if (clb) {
clb(err, req, socket);
} else {
test/lib-http-proxy-test.js
+ 22
- 2
  • View file @ d8ea6879


@@ -261,9 +261,29 @@ describe('lib/http-proxy.js', function() {
});
});
});
});
describe('#createProxyServer using the ws-incoming passes', function () {
it('should emit error on proxy error', function (done) {
var ports = { source: gen.port, proxy: gen.port };
var proxy = httpProxy.createProxyServer({
// note: we don't ever listen on this port
target: 'ws://127.0.0.1:' + ports.source,
ws: true
}),
proxyServer = proxy.listen(ports.proxy),
client = new ws('ws://127.0.0.1:' + ports.proxy);
client.on('open', function () {
client.send('hello there');
});
proxy.on('error', function (err) {
expect(err).to.be.an(Error);
expect(err.code).to.be('ECONNREFUSED');
proxyServer._server.close();
done();
});
});
it('should proxy a socket.io stream', function (done) {
var ports = { source: gen.port, proxy: gen.port };
var proxy = httpProxy.createProxyServer({
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 participant
Administrator
Reference: http-party/node-http-proxy!561
Source branch: github/fork/meteor/close-outgoing-socket

Menu

Explore Projects Groups Snippets