这是indexloc提供的服务,不要输入任何密码
Skip to content

buehren/websocket-echo-server-quarkus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Websocket Echo Server in Quarkus

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

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

Server

Run on localhost in Quarkus Dev Mode

Java 11 required.

./mvnw compile quarkus:dev

Run on localhost in Docker

A lot of disk space and RAM (~4 GB) required for building native executable.

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

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

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-quarkus-xxxxxxxxxx-xx.x.run.app/websocket

Re-create this project

Java 11 and Maven required.

mvn io.quarkus:quarkus-maven-plugin:1.12.0.Final:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=websocket-echo-server-quarkus \
    -Dextensions="undertow-websockets" \
    -DnoExamples

cd websocket-echo-server-quarkus
rm .dockerignore

# Add these files:
# README.adoc
# Dockerfile
# src/main/java/org/acme/WebSocketEndpoint.java
# src/main/resources/application.properties

About

Websocket Echo Server in Quarkus

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published