libwebsockets 运行问题

Posted zengjf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了libwebsockets 运行问题相关的知识,希望对你有一定的参考价值。

/******************************************************************************
 *                        libwebsockets 运行问题
 * 说明:
 *     编译发现libwebsockets运行出问题,解决一下。
 *
 *                                         2017-6-28 深圳 龙华樟坑村 曾剑锋
 *****************************************************************************/

一、错误现象:
    1. Run error message:
        [[email protected] ~]#  ./lwsserver 
        Parse local config over, member size: 8
        [2017/03/16 18:35:09:7201] NOTICE: Initial logging level 7
        [2017/03/16 18:35:09:7202] NOTICE: Libwebsockets version: 1.7.5 [email protected]
        [2017/03/16 18:35:09:7202] NOTICE: IPV6 not compiled in
        [2017/03/16 18:35:09:7203] NOTICE: libev support not compiled in
        [2017/03/16 18:35:09:7205] NOTICE:  Threads: 1 each 1024 fds
        [2017/03/16 18:35:09:7205] NOTICE:  mem: platform fd map:  4096 bytes
        [2017/03/16 18:35:09:7206] NOTICE:  mem: per-conn:          308 bytes + protocol rx buf
        [2017/03/16 18:35:09:7207] NOTICE:  canonical_hostname = zengjf
        [2017/03/16 18:35:09:7207] NOTICE:  Compiled with OpenSSL support
        [2017/03/16 18:35:09:7208] NOTICE:  Using non-SSL mode
        [2017/03/16 18:35:09:7309] NOTICE:  OpenSSL doesnt support ECDH
        [2017/03/16 18:35:09:7311] NOTICE:  Listening on port 9000
        starting server with thread: 1...

    2. Browser error message:
        VM900:37 WebSocket connection to ws://localhost:9000/ failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

二、解决办法:
    1. cat package/libwebsockets/libwebsockets.mk
        ...
        LIBWEBSOCKETS_CONF_OPTS = -DLWS_WITHOUT_TESTAPPS=ON -DLWS_IPV6=OFF -DLWS_SSL_SERVER_WITH_ECDH_CERT=ON
        ...

    2. cat output/build/libwebsockets-v1.7.5/CMakeLists.txt
        ...
        if (LWS_SSL_SERVER_WITH_ECDH_CERT)
            set(LWS_SSL_SERVER_WITH_ECDH_CERT 1)
        endif()
        ...

    3. cat output/build/libwebsockets-v1.7.5/lws_config.h
        ...
        /* Build with support for ipv6 */
        #undef LWS_USE_IPV6
        ...
        /* SSL server using ECDH certificate */
        #define LWS_SSL_SERVER_WITH_ECDH_CERT
        ...

 

以上是关于libwebsockets 运行问题的主要内容,如果未能解决你的问题,请参考以下文章

Libwebsocket 客户端示例

试图用 Boost::Beast 替换我的 libwebsocket 代码

如何通过 libwebsocket 发送异步数据?

带有 SSL 的 libWebsockets 服务器不输入 PEM 密码短语

如何在 Ubuntu 中安装 libwebsocket 库?

MinGW 编译libwebsockets