Git Product home page Git Product logo

echo.websocket.org's Introduction

Echo Server

This is a very simple HTTP echo server with support for websockets and server-sent events (SSE), available at https://echo-websocket.fly.dev/

The server is designed for testing HTTP proxies and clients. It echoes information about HTTP request headers and bodies back to the client.

Behavior

  • Any messages sent from a websocket client are echoed as a websocket message.
  • Visit /.ws in a browser for a basic UI to connect and send websocket messages.
  • Request /.sse to receive the echo response via server-sent events.
  • Request any other URL to receive the echo response in plain text.

Configuration

Port

The PORT environment variable sets the server port, which defaults to 8080.

Logging

Set the LOG_HTTP_HEADERS environment variable to print request headers to STDOUT. Additionally, set the LOG_HTTP_BODY environment variable to print entire request bodies.

Server Hostname

Set the SEND_SERVER_HOSTNAME environment variable to false to prevent the server from responding with its hostname before echoing the request. The client may send the X-Send-Server-Hostname request header to true or false to override this server-wide setting on a per-request basis.

Arbitrary Headers

Set the SEND_HEADER_<header-name> variable to send arbitrary additional headers in the response. Underscores in the variable name are converted to hyphens in the header. For example, the following environment variables can be used to disable CORS:

SEND_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN="*"
SEND_HEADER_ACCESS_CONTROL_ALLOW_METHODS="*"
SEND_HEADER_ACCESS_CONTROL_ALLOW_HEADERS="*"

Running the server

The examples below show a few different ways of running the server with the HTTP server bound to a custom TCP port of 10000.

Running locally

go get -u github.com/jmalloc/echo-server/...
PORT=10000 echo-server

Running under Docker

To run the latest version as a container:

docker run --detach -p 10000:8080 jmalloc/echo-server

Or, as a swarm service:

docker service create --publish 10000:8080 jmalloc/echo-server

The docker container can be built locally with:

make docker

License

This repository is a fork of https://github.com/jmalloc/echo-server, and the license remains unchanged, see LICENSE

echo.websocket.org's People

Contributors

jmalloc avatar mattheworiordan avatar boss4848 avatar ammit avatar dependabot[bot] avatar arulrajnet avatar marcofranssen avatar gaal123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.