Webhook Simulator Icon

CLI Tool

Listening and Forwarding with CLI

The Webhook Simulator CLI tool allows you to listen for incoming webhook events and forward them to your local development environment or any specified URL. This feature is crucial for testing and debugging your webhook integrations in real-time.

Starting the Listener

To start listening for webhook events, use the following command:

ws-cli listen --forward-to [yourLocalAppUrl]

Replace [yourLocalAppUrl] with the URL where you want to forward the incoming webhooks. This could be your local development server, for example: http://localhost:3000/api/webhooks

How It Works

  1. WebSocket Connection: The CLI establishes a WebSocket connection to the Webhook Simulator server.
  2. Authentication: It uses your stored authentication token to subscribe to your private channel.
  3. Event Listening: Once connected, it listens for incoming webhook events on your channel.
  4. Forwarding: When an event is received, it's forwarded to the specified URL.
  5. Response Handling: The CLI captures the response from your forwarding URL and sends it back to the Webhook Simulator server.

Features

  • Real-time Event Processing: Events are processed and forwarded as soon as they are received.
  • Colorized Output: The CLI uses color-coded output to distinguish between different types of information (events, responses, errors).
  • JSON Formatting: Incoming payloads and responses are prettified for easy reading.
  • Error Handling: The CLI gracefully handles connection issues and attempts to reconnect automatically.

Monitoring Events

While the listener is running, you'll see real-time output in your terminal:

  • Incoming event details
  • Forwarded payload
  • Response from your endpoint
  • Any errors or connection issues

Best Practices

  1. Local Testing: Use localhost URLs for testing webhooks in your local development environment.
  2. Error Monitoring: Keep an eye on the CLI output for any errors in your webhook handling.
  3. Continuous Running: For ongoing development, you might want to run the CLI in a separate terminal window or use a terminal multiplexer like tmux.

Stopping the Listener

To stop listening, simply press Ctrl+C in your terminal. The CLI will gracefully close the WebSocket connection and exit.

Troubleshooting

  • If you're not receiving events, ensure your CLI is authenticated and your webhook URL is correctly set up in the Webhook Simulator dashboard.
  • Check your firewall settings if you're having trouble with local forwarding.
  • If you encounter persistent connection issues, try restarting the CLI or logging out and back in.

By using the listen and forward functionality, you can effectively test and debug your webhook handlers in your local environment, ensuring they're ready for production use.

Previous
Authentication