Skip to content

An example of using http-proxy to proxy WebSocket requests to a separate server

Notifications You must be signed in to change notification settings

MethodGrab/socketio-proxy-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Socket.io Proxy Boilerplate

An example of using http-proxy to proxy WebSocket requests to a separate server.

Usage

  • npm install
  • npm start
    (or npm run start:dev to use nodemon & show debug messages)
  • Open http://localhost:4000 in the browser and check the console

To show debug messages in the browser use:

localStorage.setItem( 'debug', 'socket.io-client:*,-socket.io-client:socket' );

Testing

To verify that sockets are being used instead of polling, open the dev tools Network tab and find the request using the websocket protocol.
It should have a status code of 101 Switching Protocols and it's frames tab should show all the incoming ping messages from the server.

Notes

  • Socket.io will still do some (~3) initial polling requests before upgradeing to a WebSocket connection.
    If you change the clientside transports to transports : ['websocket'] these initial polling requests will stop but you lose the polling fallback.

About

An example of using http-proxy to proxy WebSocket requests to a separate server

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published