Socket
Socket
Sign inDemoInstall

wspr

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    wspr

WebSocket proxy for post http requests. Perfect for testing purposes/mocks


Version published
Weekly downloads
529
decreased by-48.44%
Maintainers
1
Install size
84.6 kB
Created
Weekly downloads
 

Readme

Source

styled with prettier PRs Welcome

WSPR

WebSocket proxy for post http requests. Perfect for testing purposes/mocks 🚀

wssExample

Installation

npm i -g wspr

Usage

Just run

wspr

after, you will see output with 2 urls:

WebSocket server started ws://localhost:3005
HTPP proxy server started http://localhost:3006

Broadcast message to clients:

To broadcast message to clients send a post requests with a string/json body (via postman or curl) to http enpoint provided on the previous step.

curl -d "{"hello": "world"}" -X POST http://localhost:3006

Websocket over secure connection

If you want to run the websocket server over a secure connection, follow these steps:

  1. create self signed certificates: https://letsencrypt.org/docs/certificates-for-localhost/#making-and-trusting-your-own-certificates

  2. trust the self signed certs, eg on mac: https://tosbourn.com/getting-os-x-to-trust-self-signed-ssl-certificates/

  3. pass the paths to the certificate and key using the --cert and --key CLI args, eg:

wspr --cert=./localhost.crt --key=./localhost.key
  1. you should see the websocket is now running over wss:
WebSocket server started wss://localhost:3005

Enjoy 🚀🥤

Keywords

FAQs

Last updated on 14 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc