Basic WebSocket Server

This app demonstrates a WebSocket server running on the device.

API Features Demonstrated


This app works on:

Requirements and Prerequisites

This app requires a ZentriOS evaluation board, such as an AMWx06-E03 (Moray).


The initialization file settings.ini is packaged into the .zap file downloaded to the device.

The file websocket_server_demo.html is downloaded to the device.


This app demonstrates a WebSocket server running on the device.

The device also runs an HTTP Server that serves out a web page to a client system.

On the client system, entering a message in the demonstration web page Message text box sends the message to the server, which then echoes the result back to the client. The web page displays the echoed message in the Message Log text area.

Instructions for Use

Open a ZentriOS serial terminal to the device. See Getting Started, Opening a ZentriOS Terminal.

This app assumes your ZentriOS device is set up with the credentials to join your local network. If you have not already set up network credentials, on the ZentriOS terminal, run the commands:

network_up -s

See the Wi-Fi Command API documentation for network_up and save.

After compiling, downloading and running the app, wait until the device is connected to the local network.

Then in a web browser on a computer or mobile device connected to the same network, open the URL http://websocket_server.local/.

On the WebSocket Demonstration page, in the Device IP or Name text box, specify the name websocket_server and click Open WebSocket

When the Session Log text area displays WebSocket open..., type a message in the Message text box and press Enter.

In the Message Log text area, the messages you send from the WebSocket client are shown in orange. Messages echoed from the WebSocket server are shown in blue.









See also: