Skip to content

lucee/extension-websocket-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lucee WebSocket Client Extension

Java CI

WebSocket client support for Lucee CFML — connect to any WebSocket server from CFML and handle messages via listener components. Powered by nv-websocket-client.

Requires Lucee 6.2+ (supports both Lucee 6.x and 7.x / Jakarta).

Installation

Install via Lucee Admin, or pin in your environment:

LUCEE_EXTENSIONS=org.lucee:websocket-client-extension:2.3.0.9-SNAPSHOT

Documentation

What's Included

  • CreateWebSocketClient( endpoint, component ) BIF — connects to a WebSocket server and returns a client socket you can sendText() / sendBinary() / disconnect() on.
  • Listener callbacks — your component receives onMessage, onBinaryMessage, onClose, onError, onPing, onPong.
  • Per-message deflatepermessage-deflate extension enabled by default.

Quick Example

// Listener component
component {

    function onMessage( message ) {
        systemOutput( "received: " & message, true );
    }

    function onError( type, cause ) {
        systemOutput( "error [#type#]: #cause.getMessage()#", true );
    }

    function onClose() {
        systemOutput( "connection closed", true );
    }

}
ws = CreateWebSocketClient( "ws://localhost:8080/ws/EchoListener", new Listener() );
ws.sendText( "hello server" );
// ...
ws.disconnect();

Related

  • extension-websocket — the server-side companion for hosting WebSocket endpoints in Lucee. Its integration tests exercise the full client⇄server loop (connect, send, echo, disconnect) and provide the real coverage for sendText() / disconnect() in this extension.