Skip to content

provegard/tinyws

Repository files navigation

TinyWS

Build Status Maven Central

What is it?

A tiny WebSocket server written in Java 8.

Why?

Because it's fun and I wanted to be able to have a WebSocket server without several megabytes of dependencies.

Status

Version 0.0.6.

It passes all tests of Autobahn|Testsuite version 0.7.5, except 12.* and 13.* (compression using the permessage-deflate extension).

Features:

  • Standards-compliant (according to AutoBahn|Testsuite at least)
  • Tiny—one file
  • NO external dependencies
  • Requires Java 8 (Travis-CI currently runs the tests against 1.8.0_31)
  • Multiple endpoints
  • Configurable Maximum frame size (controls fragmentation)
  • Configurable address and port
  • Configurable backlog
  • Logging via simple interface—no dependency on any particilar log framework
  • SSL (WSS) support
  • Fallback handler, for endpoints without a WebSocket handler

Limitations:

  • No frame compression support
  • No extension support
  • Maximum payload size is 0x7fffffff (2147483647) bytes
  • Only talks protocol version 13 (mandated by RFC 6455)

Running tests

./gradlew test

Note that the tests requires wstest to be installed and available on the path.

Examples

The echoserver folder contains an—drum roll—echo server!

Autobahn test suite

Create an Autobahn configuration file named fuzzingclient.json, e.g.:

{
  "servers": [{ "url": "ws://127.0.0.1:9001" }],
  "cases": ["*"],
}

Run the echo server (which starts on port 9001):

./gradlew run

Run wstest:

wstest -m fuzzingclient

For SSL, change fuzzingclient.json so that it uses a wss URL instead:

{
  "servers": [{ "url": "wss://127.0.0.1:9001" }],
  "cases": ["*"],
}

...and then run the echo server like this:

./gradlew -Pargs="wss/keystore.jks storepassword keypassword" run

(Yes, those are the actual passwords—they're not placeholders.)

Usage/documentation

TBD

Changelog

See CHANGELOG.md.

Author

Per Rovegård

Twitter: @provegard

License

MIT, https://per.mit-license.org/2017

See also the LICENSE file.

About

Tiny WebSocket server in Java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages