Skip to content

Commit

Permalink
Benchmarks still missing on 1.0 due to IndexedTables. Removed HttpSer…
Browse files Browse the repository at this point in the history
…ver tests. (#109)

modified:   README.md                 rephrasing
modified:   benchmark/REQUIRE         remove HTTP
modified:   benchmark/benchmark.jl    remove HTS
deleted:    benchmark/logs/benchmark_results_readable.log
modified:   benchmark/ws_jce.jl       Don't use HTTP
deleted:    examples/serve_verbose/svg/ws_neighborhood.svg
deleted:    logutils/log_httpserver.jl
modified:   logutils/log_ws.jl        Don't use Requires
modified:   logutils/logutils_ws.jl   Don't use Requires
deleted:    test/optional/browsertest.html
deleted:    test/optional/browsertest.jl
deleted:    test/optional/browsertest2.html
deleted:    test/optional/favicon.ico
deleted:    test/optional/functions_log_test.jl
deleted:    test/optional/functions_open_browsers.jl
deleted:    test/optional/functions_server.jl
deleted:    test/optional/handler_functions_events.jl
deleted:    test/optional/handler_functions_websockets_general_test.jl
deleted:    test/optional/handler_functions_websockets_subprotocol_test.jl
deleted:    test/optional/phantom.js
  • Loading branch information
hustf authored Aug 14, 2018
1 parent 0a5f040 commit 33f2905
Show file tree
Hide file tree
Showing 20 changed files with 17 additions and 2,448 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
Server and client side [Websockets](https://tools.ietf.org/html/rfc6455) protocol in Julia. WebSockets is a small overhead message protocol layered over [TCP](https://tools.ietf.org/html/rfc793). It uses HTTP(S) for establishing the connections.

## Getting started
On Julia pre 0.6, see an earlier version of this repository.
On Julia 0.7 or newer :
On Julia pre 0.7, see an earlier version of this repository.

```julia
(v0.7) pkg>add WebSockets
julia> using WebSockets
julia> varinfo(WebSockets)
help?> serve
help?> WebSockets.open
julia> cd(joinpath((WebSockets |> Base.pathof |> splitdir)[1], "..", "examples"))
julia> readdir()
julia> include("chat_explore.jl")
Expand All @@ -36,25 +36,26 @@ Client side websockets are created by calling `WebSockets.open` (with a server r
julia> cd(joinpath((WebSockets |> Base.pathof |> splitdir)[1], "..", "examples"))
julia> include("client_repl_input.jl")
```
We recommend `readguarded` and `writeguarded` instead of `read`and `write` for more effective debugging.

### Debugging server side connections

Server side websockets are asyncronous [tasks](https://docs.julialang.org/en/stable/stdlib/parallel/#Tasks-1), which makes debugging harder. The error messages may not spill into the REPL. There are two interfaces to starting a server:
Server side websockets are asyncronous [tasks](https://docs.julialang.org/en/stable/stdlib/parallel/#Tasks-1), which makes debugging harder. The error messages may not spill into the REPL. There are two interfaces to starting a server which includes a websocket handling function:

##### Using WebSockets.serve
Error messages are directed to a channel. See inline docs: ?Websockets.serve.

##### Using HTTP.listen
Error messages are by default sent as messages to the client. This is not good practice if you're serving pages to the internet.
Error messages are by default sent as messages to the client. This is not good practice if you're serving pages to the internet, but nice while developing locally.

## What is nice with WebSockets.jl?
Some packages rely on WebSockets for communication. You can also use it directly:

- reading and writing between entities you can program or know about
- low latency, high speed messaging
- implement your own 'if X send this, Y do that' subprotocols
- implement registered [websocket subprotocols](https://www.iana.org/assignments/websocket/websocket.xml#version-number)
- heartbeating, relaying
- implementing your own 'if X send this, Y do that' subprotocols
- registered [websocket subprotocols](https://www.iana.org/assignments/websocket/websocket.xml#version-number) for e.g. remote controlled hardware
- heartbeating, relaying user interaction to backend simulations
- build a network including browser clients
- convenience functions for gatekeeping
- putting http handlers and websocket coroutines ('handlers') in the same process can be a security advantage. It is good practice to modify web page responses to include time-limited tokens in the wsuri.
Expand All @@ -63,9 +64,9 @@ WebSockets are well suited for user interactions via a browser or [cross-platfor

The /logutils folder contains some specialized logging functionality that is quite fast and can make working with multiple asyncronous tasks easier. See /benchmark code for how to use. Logging may be moved entirely out of WebSockets.jl in the future.

You can also have a look at alternative Julia packages: [DandelionWebSockets](https://github.com/dandeliondeathray/DandelionWebSockets.jl) or the implementation currently part of HTTP.jl.
You can also have a look at alternative Julia packages: [DandelionWebSockets](https://github.com/dandeliondeathray/DandelionWebSockets.jl) or the implementation currently part of [HTTP.jl](https://github.com/JuliaWeb/HTTP.jl).

## What are the main downsides to WebSockets (in Julia)?
## What are the main downsides to using WebSockets.jl directly?

- Logging. We need customizable and very fast logging for building networked applications.
- Compression is not implemented.
Expand All @@ -74,7 +75,7 @@ You can also have a look at alternative Julia packages: [DandelionWebSockets](ht
- Garbage collection, which increases message latency at semi-random intervals. See benchmark plots.
- If a connection is closed improperly, the connection task will throw uncaught ECONNRESET and similar messages.
- TCP quirks, including 'warm-up' time with low transmission speed after a pause. Heartbeats can alleviate.
- Since 'read' is a blocking function, you can easily end up reading indefinitely from both sides. See the 'close' function code for an example of non-blocking reads with a timeout.
- Since `read` is a blocking function, you can easily end up reading indefinitely from any side of the connection. See the `close function code for an example of non-blocking read with a timeout.

## Errors after updating?

Expand Down
3 changes: 1 addition & 2 deletions benchmark/REQUIRE
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Being placed in the benchmark folder, this file has no effect on Julia.
# To run benchmarks, you may need to Pkg.add("..package below...")
HTTP
IndexedTables
UnicodePlots
Requires
Requires
5 changes: 2 additions & 3 deletions benchmark/benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Server The side of a connection which accepts.
Origin Sender
Destination Receiver
HTS HTTP server
JCE Julia Client Echoing (only compatible with HTS)
BCE Browser Client Echoing (compatible with HTS and HSS)
JCE Julia Client Echoing
BCE Browser Client Echoing
Note we use 'inverse speed' below. In lack of better words, we call this speed.
This is more compatible with BenchmarkTools and more directly useful.
Expand Down Expand Up @@ -40,7 +40,6 @@ serverbandwidth [ns/b] = [s/GB]
----- TODO ----
Not used:
** HSS HttpServer server
** delay [ns] Time usefully spent between received message and start of reply
** clientRTT [ns] Round-trip-time for a message initiated by client
** serverRTT [ns] Round-trip-time for a message initiated by server
Expand Down
Loading

0 comments on commit 33f2905

Please sign in to comment.