Skip to content

buehren/websocket-echo-server-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Websocket Echo Server in Python

  1. Start the Server (see below for multiple options).

  2. Connect with a Client (in another shell).

Server

Run on localhost in Python

Python 3 required.

python3 -m pip install -r requirements.txt

python3 wsecho.py

Run on localhost in Docker

docker build -f Dockerfile -t websocket-echo-server-python .

docker run -i --rm -p 8080:8080 websocket-echo-server-python

Run on Google Cloud Run

Run on Google Cloud

Note the URL displayed after Your application is now live here.

Client

Download Python WebSocket Client

Python 3 required for websocket_client.

wget https://github.com/websocket-client/websocket-client/raw/master/bin/wsdump.py

Connect with Python WebSocket Client

# Server running on localhost:

python3 wsdump.py ws://127.0.0.1:8080/websocket
# Now enter texts and press RETURN.
# The texts are echoed by the server.


# Server running on Google Cloud Run:

python3 wsdump.py wss://websocket-echo-server-python-xxxxxxxxxx-xx.x.run.app/websocket
# Use the hostname that was displayed in Cloud Shell when deploying the server app to Cloud Run.

Dart WebSocket Client

Dart required.

dart pub get

# echo.websocket.org is used by default:
dart run wsclient.dart

# Server running on localhost:
dart run wsclient.dart --url ws://localhost:8080/websocket

# Server running on Google Cloud Run:
dart run wsclient.dart --url wss://websocket-echo-server-python-xxxxxxxxxx-xx.x.run.app/websocket

About

Websocket Echo Server in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published