samples/net/sockets/websocket_client/README.html · samples/net/sockets/websocket_client/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · Networking · WebSocket

WebSocket Client

Board 또는 QEMU client를 Python server나 websocketd에 연결하고 TLS overlay를 구성합니다.

Official pathsamples/net/sockets/websocket_client/README.html
Source filesamples/net/sockets/websocket_client/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

Certificate·private key, Linux server 두 선택지와 net-tools TLS 제한을 보존합니다.

Handshake

HTTP · HTTPS

Transport

WebSocket

Servers

Python · websocketd

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 F89C9AD7ED55B8402A30736CD71486E22B9F1F015964B805C4E6676FB10B6965
.. zephyr:code-sample:: sockets-websocket-client
   :name: WebSocket Client
   :relevant-api: bsd_sockets websocket

   Implement a Websocket client that connects to a Websocket server.

Overview
********

This sample application implements a Websocket client that will do an HTTP
or HTTPS handshake request to HTTP server, then start to send data and wait for
the responses from the Websocket server.

The source code for this sample application can be found at:
:zephyr_file:`samples/net/sockets/websocket_client`.

Requirements
************

- :ref:`networking_with_host`

Building and Running
********************

You can use this application on a supported board, including
running it inside QEMU as described in :ref:`networking_with_qemu`.

Build websocket-client sample application like this:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/websocket_client
   :board: <board to use>
   :conf: <config file to use>
   :goals: build
   :compact:

Enabling TLS support
====================

Enable TLS support in the sample by building the project with the
``overlay-tls.conf`` overlay file enabled using these commands:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/websocket_client
   :board: qemu_x86
   :conf: "prj.conf overlay-tls.conf"
   :goals: build
   :compact:

An alternative way is to specify ``-DEXTRA_CONF_FILE=overlay-tls.conf`` when
running ``west build`` or ``cmake``.

The certificate and private key used by the sample can be found in the sample's
:zephyr_file:`samples/net/sockets/websocket_client/src/` directory.


Running websocket-server in Linux Host
======================================

You can run this ``websocket-client`` sample application in QEMU
and run the ``zephyr-websocket-server.py`` (from net-tools) on a Linux host.
Other alternative is to install `websocketd <http://websocketd.com/>`_ and
use that.

To use QEMU for testing, follow the :ref:`networking_with_qemu` guide.

In a terminal window you can do either:

.. code-block:: console

    $ ./zephyr-websocket-server.py

or

.. code-block:: console

    $ websocketd --port=9001 cat

Run ``websocket-client`` application in QEMU:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/websocket_client
   :host-os: unix
   :board: qemu_x86
   :conf: prj.conf
   :goals: run
   :compact:

Note that ``zephyr-websocket-server.py`` or ``websocketd`` must be running in
the Linux host terminal window before you start the ``websocket-client``
application in QEMU. Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.

Current version of ``zephyr-websocket-server.py`` found in
`net-tools <https://github.com/zephyrproject-rtos/net-tools>`_ project, does
not support TLS.

Part 3

한국어 전문 번역

개요

이 sample application은 HTTP server에 HTTP 또는 HTTPS handshake request를 보낸 뒤 data 전송을 시작하고 WebSocket server의 response를 기다리는 WebSocket client를 구현합니다.

이 sample application의 source code는 samples/net/sockets/websocket_client에서 찾을 수 있습니다.

요구 사항

빌드 및 실행

이 application은 지원되는 board에서 사용할 수 있으며, Networking with QEMU에서 설명하는 방식으로 QEMU 안에서도 실행할 수 있습니다.

WebSocket client sample application의 일반 build 방법은 다음과 같습니다.

west build -b <board to use> samples/net/sockets/websocket_client -- -DCONF_FILE=<config file to use>

TLS 지원 활성화

overlay-tls.conf overlay file을 활성화해 project를 build하면 sample의 TLS 지원을 켤 수 있습니다.

west build -b qemu_x86 samples/net/sockets/websocket_client -- -DCONF_FILE="prj.conf overlay-tls.conf"

다른 방법으로 west build 또는 cmake를 실행할 때 -DEXTRA_CONF_FILE=overlay-tls.conf를 지정할 수 있습니다.

Sample이 사용하는 certificate와 private key는 samples/net/sockets/websocket_client/src/ directory에서 찾을 수 있습니다.

Linux Host에서 WebSocket server 실행

QEMU에서 이 websocket-client sample application을 실행하고 Linux host에서는 net-tools의 zephyr-websocket-server.py를 실행할 수 있습니다. 다른 방법으로 websocketd를 설치해 사용할 수도 있습니다.

QEMU test 설정은 Networking with QEMU guide를 따릅니다.

Terminal window에서 다음 두 방법 중 하나를 사용합니다.

$ ./zephyr-websocket-server.py

또는:

$ websocketd --port=9001 cat

그 다음 QEMU에서 websocket-client application을 실행합니다.

west build -b qemu_x86 samples/net/sockets/websocket_client -- -DCONF_FILE=prj.conf
west build -t run

QEMU에서 websocket-client application을 시작하기 전에 Linux host terminal window에서 zephyr-websocket-server.py 또는 websocketd가 실행 중이어야 합니다. CTRL+A에 이어 x를 눌러 QEMU를 종료합니다.

현재 net-tools project에 있는 zephyr-websocket-server.py version은 TLS를 지원하지 않습니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.