Basic WebSocket Server

This app demonstrates a WebSocket server running on the device.

API Features Demonstrated


This app works on:

Requirements and Prerequisites

Requires a Gecko OS evaluation board, such as a WGM160P_eval.

Other Gecko OS hardware can also be used by changing the source of the logged data to suit your device.


The initialization file settings.ini is packaged into the App 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 Gecko OS serial terminal to the device. See Getting Started, Opening a Gecko OS Terminal.

This app assumes your Gecko OS device is set up with the credentials to join your local network. If you have not already set up network credentials, on the Gecko OS 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.