socketless-server

Websocket microservice that routes to / interacts with serverless lambdas

Usage no npm install needed!

<script type="module">
  import socketlessServer from 'https://cdn.skypack.dev/socketless-server';
</script>

README

socketless-server

WIP: A websocket router for serverless apps. Follow on Github.

npm CircleCI coverage MIT License

See https://github.com/socketless/socketless-project.

Quick Start

const SocketlessServer = require('socketless/server');

new SocketlessServer(/* optional config */);
# Lambdas to be called on new connection or incoming message
SOCKETLESS_ON_CONNECT_URL=
SOCKETLESS_ON_MESSAGE_URL=

# Ports (and their defaults) to accept new connections
SOCKETLESS_WEBSOCKET_PORT=4000
SOCKETLESS_REST_PORT=4000

# TODO
SOCKETLESS_REST_ALLOW=127.0.0.1
REDIS_DB=

API

onConnect

onMsg

SLS requests

An incoming websocket message (from a websocket client, i.e. browser), that begins with "SLS " (capital 'SLS' followed by a single space), will not be sent to onMsg lambdas. Instead, certain commands will be answered directly by the server.

  • SLS PING <payload> The server will respond to the client with 'SLS PONG '. Useful to keep the connection alive and check latency. Also known as heartbeats.