[Libwebsockets] Issue sending data

Derrill Vezina dvezina at caron-eng.com
Mon Jan 2 22:50:39 CET 2017


I am currently using libwebsockets to act as a websocket server from the most up to date git repository master branch with a very simple implementation to get things up and running (this is my first time using the library).

My goal is simply to send a packet out every 2 seconds, and print out any data received by any client. After 2 seconds, I try to call lws_callback_on_writable_all_protocol() to write data and the callback is not firing for LWS_CALLBACK_SERVER_WRITEABLE or LWS_CALLBACK_CLIENT_WRITEABLE.

I have attached main.cpp code I am currently using and the test .html page that I grabbed from the net. After a connection is established, the callback on writeable is not getting fired. Is there something I am missing here with my protocol configuration that someone could help me with that would make it so I am unable to send data?

This is my console output:

[2017/01/02 16:45:03:1580] NOTICE: Initial logging level 7
[2017/01/02 16:45:03:1581] NOTICE: Libwebsockets version: 2.1.0 dvez at ubuntu-v2.0.0-217-g58a26eb
[2017/01/02 16:45:03:1581] NOTICE: IPV6 not compiled in
[2017/01/02 16:45:03:1581] NOTICE: libev support not compiled in
[2017/01/02 16:45:03:1581] NOTICE: libuv support not compiled in
[2017/01/02 16:45:03:1581] NOTICE:  Threads: 1 each 65536 fds
[2017/01/02 16:45:03:1585] NOTICE:  mem: platform fd map: 524288 bytes
[2017/01/02 16:45:03:1585] NOTICE:  Compiled with OpenSSL support
[2017/01/02 16:45:03:1585] NOTICE:  SSL disabled: no LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT
[2017/01/02 16:45:03:1585] NOTICE: Creating Vhost 'default' port 4500, 2 protocols, IPv6 off
[2017/01/02 16:45:03:1588] NOTICE:  Listening on port 4500
[2017/01/02 16:45:03:1588] NOTICE:  mem: per-conn:          568 bytes + protocol rx buf
[2017/01/02 16:45:03:1588] NOTICE:  canonical_hostname = ubuntu
Websocket server started and is listening
[2017/01/02 16:45:03:1599] NOTICE: lws_protocol_init
Websocket protocol initialized
[2017/01/02 16:45:04:2919] NOTICE: Accepted wsi 0x18dfb90 to context 0x18d6760, tsi 0
Websocket session started
Data received: Echo
Timer expired
Websocket has ended session
[2017/01/02 16:47:17:5549] NOTICE: lws_context_destroy: ctx 0x18d6760
Websocket protocol destroyed
[2017/01/02 16:47:17:5555] NOTICE: lws_context_destroy2: ctx 0x18d6760

Best regards,

DV
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20170102/26d08cef/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: application/octet-stream
Size: 2833 bytes
Desc: main.cpp
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20170102/26d08cef/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20170102/26d08cef/attachment-0001.html>


More information about the Libwebsockets mailing list