Testing Your WebSockets Server

One way to easily test your server is to use the wscat npm module. wscat is a tool for connecting to and communicating with a WebSockets server. The module provides a command-line program that you will use as a chat client.

Open a second terminal window and install wscat globally. You may need to run this command with administrator privileges. (If you need a refresher, refer to Chapter 1.)

npm install -g wscat

When wscat is installed, you are ready to connect to your WebSockets server.

In the second terminal window, run the command wscat -c ws://localhost:3001. You should see the message connected (press CTRL+C to quit) in the second terminal window and 'client connection established' in the first ...

Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.