Skip to content
GitLab
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
  • !349

Misleading documentation for Websockets via .createServer

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/itsjamie/patch-1 into master Feb 22, 2013
  • Overview 2
  • Commits 2
  • Pipelines 0
  • Changes 1

Created by: itsjamie

It's said its handled automatically, however from my experience this isn't the whole story, and to save someone else a headache this should be remedied in the docs.

Just some background I had a connect middleware for no-www, and options..

var options = {
    hostnameOnly: true,
    router: {
        'api.[snip]': '127.0.0.1:3001',
        '[snip]': '127.0.0.1:3000'
    }
};

var server = httpProxy.createServer(
    nowww(false),
    options
);

server.listen(80, function() {
  console.log('proxy up');
});

The websockets connections aren't made automatically because I was using middleware, so you need to add..

server.on('upgrade', function(req, socket, head) {
    server.proxy.proxyWebSocketRequest(req, socket, head);
});

This should just be documented somewhere is all. It would have saved me the hour of "hmm, why is this falling back to xhr-polling?" time and source-reading lines to see the "magic"

if (!callback) {
  proxy.proxyWebSocketRequest(req, socket, head);
}

But, more than willing to give up that hour for the total amount of time you've saved me 👍

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/itsjamie/patch-1