streamly-websockets-tls: Secure WebSockets, and WebSockets by URL, with Streamly

[ bsd3, library, network, streamly, web ] [ Propose Tags ] [ Report a vulnerability ]

The convenient face of streamly-websockets: open a WebSocket from its URL, the scheme (ws or wss) choosing between plain TCP and TLS through streamly-network-tls, and serve WebSockets over TLS.


[Skip to Readme]

Modules

  • Streamly
    • External
      • Network
        • WebSocket
          • Streamly.External.Network.WebSocket.TLS

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.19 && <4.22), bytestring (>=0.12 && <0.13), network (>=3.2 && <3.3), streamly-http (>=0.1 && <0.2), streamly-network-tls (>=0.1 && <0.2), streamly-websockets (>=0.1 && <0.2) [details]
Tested with ghc ==9.8.4 || ==9.10.3 || ==9.12.4
License BSD-3-Clause
Author Xavier Dectot
Maintainer Xavier Dectot <xavier@wheredoibegin.fr>
Uploaded by GdeVolpiano at 2026-11-28T11:12:21Z
Category Network, Web, Streamly
Home page https://github.com/GuillaumedeVolpiano/streamly-websockets-tls
Source repo head: git clone https://github.com/GuillaumedeVolpiano/streamly-websockets-tls.git
Distributions
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs pending
Build status unknown [no reports yet]

Readme for streamly-websockets-tls-0.1.0.0

[back to package description]

streamly-websockets-tls

Secure WebSockets, and WebSockets by URL, with Streamly. This is the convenient face of streamly-websockets: the scheme of a URL (ws or wss) chooses between plain TCP and TLS (through streamly-network-tls), and a server can serve over TLS.

A client:

{-# LANGUAGE OverloadedStrings #-}

import Streamly.External.Network.WebSocket (Message (TextMessage), receive,
                                            send)
import Streamly.External.Network.WebSocket.TLS (withUrl)

main :: IO ()
main = withUrl "wss://example.org/chat" $ \connection -> do
  send connection (TextMessage "hello")
  receive connection >>= print

A server over TLS that sends back what it receives:

{-# LANGUAGE OverloadedStrings #-}

import Streamly.Data.Fold (drainMapM)
import Streamly.Data.Stream (fold)
import Streamly.External.Network.WebSocket.Server (defaultServerOptions,
                                                   messages, send)
import Streamly.External.Network.WebSocket.TLS (loadCredentials, serveSecure)

main :: IO ()
main = do
  credentials <- loadCredentials "certificate.pem" "key.pem"
  serveSecure credentials "0.0.0.0" 8443 defaultServerOptions $ \_ connection ->
    fold (drainMapM (send connection)) (messages connection)

What it gives

  • withUrl: the WebSocket of a ws or wss URL, checked against the certificates of the system.
  • urlConfig and withConnectionAt: the same in two steps, to change the configuration (extra headers, bounds) or the certificates trusted.
  • serveSecure and serveSecureSocket: a server over TLS, with the certificate and the key that loadCredentials reads.

Building

To build against copies of the libraries this package is built on (streamly-websockets, streamly-network-tls, streamly-http) checked out next to this repository, pass --project-file=cabal.project.siblings.