Close
Type at least 1 character to search
Back to top

Sockets II

The Postman websocket request.

Connecting to your server through a Postman websocket request.

Today we’re doing what is essentially the same thing as in Websockets Introduction, but with a slight twist: Instead of sending a message to the echo server using Safari, we’ll send a message using Postman.

So if you haven’t used Postman, this is a chance to get started. And if you haven’t used Postman with a websocket, this is a chance to get better.

Like yesterday:

1. If you haven’t already: Download Docker for the Mac.

2. If you haven’t already: Set up a websocket on a server running in your Docker container.

3. If you haven’t already: Connect to the Docker container from Safari.

4. Today: Download Postman for the Mac.

5. Today: Set up a websocket in Postman.

6. Today: Send messages from both Postman and Safari and see the conversation in the Docker container.

1. Download Docker:

Go to Docker.com and download the appropriate version for your intel or apple silicon mac.

After installing, follow the directions here:

https://docs.docker.com/desktop/install/mac-install/

which I summarize as:

$ sudo hdiutil attach Docker.dmg

$ sudo /Volumes/Docker/Docker.app/Contents/MacOS/install

$ sudo hdiutil detach /Volumes/Docker

Get Docker running on your mac, i.e., start the app. If the Docker container isn’t responding perhaps you need to make sure it’s running. Click the checkmark next to the echo-server container and hit the run button.

Now go to Safari and enter the following

http://localhost:10000/.ws

You should see an interface that will allow you to enter messages and have them echo back to you.

Now download Postman if you don’t already have it. Get it from www.postman.com.

Open the app and in the Workspaces menu, create a workspace. Then select it.

Above the list of items in your collection — which might be empty — there is a button labeled ‘New.’

Hit the New button and select ‘WebSocket Request BETA’

In the resulting window, we’re going to create a websocket request, just like you did for Safari.

Enter localhost:1000.

Enter a message in the New message area.

Assuming your Docker instance of the echo server is running, you can now hit the send button.

Go back to the Docker app, and if you’re looking at a list of containers, single click the echo server:

You can see the message you just sent from Postman in the list of messages.

Repeat this from Safari. And back in docker you can now also see the message from Safari. Congrats! you are communicating from two different sources to your echo server in Docker.

 

Designers

James Robinson Douglas Stewart

Date