GithubHelp home page GithubHelp logo

cppwebsockets's People

Contributors

amfg avatar arades79 avatar atombs avatar hdbaggy avatar mnisjk avatar nesnes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cppwebsockets's Issues

Proposed solution to "double free or corruption (out)"

I downloaded the code, and the examples didn't work.
I located what I think is an error in the buffer management.
The data type for the data waiting to be sent shouldn't be const char *, but strings.

struct Connection
{
    list<string>       buffer;     // <-- string and not const char*
    map<string,string> keyValueMap;
    time_t             createTime;
};

`
A copy of the incoming data should be made when pushing to the buffer:

A const char is just a pointer. If a pointer is pushed onto the buffer, and the pointer is for some reason no longer valid, then the buffer contains ... invalid data.
That's what I found when I put some debug statements into the code.
Here is what the echo server told me:

[cppWebSockets] Callback Receive
[cppWebSockets] Received: hjghjk
[cppWebSockets] send, socketID = 8 data = 'hjghjk'
[cppWebSockets] Callback Server Writeable, fd = 8
[cppWebSockets] == Elements in buffer: 1
[cppWebSockets] == Element : ���� [cppWebSockets] Sending '����'

The buffer elements was first pushed to the buffer in the WebSocketServer::send, and when the callback receive function asked for them, they were no longer valid.

Changing the datatype to string as shown solved the problem.

Messages that are 3-4 k can be fragmented which isn't handled correctly in the callback and wait() hangs until connection

per warmcat/libwebsockets#1255
https://libwebsockets.org/lws-api-doc-main/html/md_READMEs_README_8coding.html

The receive buffer size in lws_protocols could be increased or the user parameter could be used per the link above. Neither of these approaches is very attractive in terms of preserving the general structure of the library.

In addition, the wait() method calls lws_service w/ a timeout that has been obsoleted blocking until a connection is made.

lws_get_internal_extensions() not found !!

g++ -w -DLOG_TO_STDOUT=1 -oechoserver ../../Util.cpp ../../WebSocketServer.cpp echoServer.cpp -lwebsockets
../../WebSocketServer.cpp: In constructor ‘WebSocketServer::WebSocketServer(int, std::string, const string&)’:
../../WebSocketServer.cpp:99:23: error: ‘lws_get_internal_extensions’ was not declared in this scope
99 | info.extensions = lws_get_internal_extensions( );
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:2: hellomake] Error 1

memory leak when sending large strings

Hey,

While working on a project that streams large JSON packets of sensor data, I noticed memory usage increasing slowly over time.

I ran through valgrind and it wouldn't find the error, since it wasn't a heap memory leak.

Eventually I found that passing in a c string, and changing all the send related functions to meet this fixed the issue.

I've submitted a PR with the changes I've made for you to look over.

Thanks

echoserver Segfault with libwebsockets v1.7.2

Just tested the echoserver with both libwebsocket v1.7.2 and libwebsocket v1.7-stable. I get a segfault on the first message reception. Here is my output:

$ ./echoserver
[cppWebSockets] Not using SSL
[cppWebSockets] Server started on port 8080
[cppWebSockets] New connection
[cppWebSockets] Received: asdasd
[cppWebSockets] Error: Error writing to socket on socketID '8'
[cppWebSockets] Error: Error writing to socket
Segmentation fault (core dumped)

issues with the lib on embedded systems

the cppWebSocket is using too much CPU (about 70%) in my embedded board (ARM v7 with 251M of RAM) . I just had to modify some lines in the code and I get nearly 0% of CPU usage.

Needed some fixes with the performance ;)

CMake build/install CMakeLists.txt

I implemented a simple build and install using cmake (I don't pretend to be a CMake guru; but it works for me).
CMakeLists.txt
I've only tested on Linux; but I expect it to work on other platforms that support CMake. I didn't update the examples to use CMakeLists.txt as the Makefile(s) provided are simple enough.

Yet another "double free or corruption (out)"

Steps to reproduce:

  1. compile and install libwebsockets-2.3
  2. compile example echoserver from cppWebSockets
  3. run echoserver
  4. open index.html (from echoserver directory) in a browser (here: firefox 55.0.2)
  5. enter a long string in the textbox and click send

On one system (ubuntu 16.04), it crashes with strings of length 16, like "1234567890123456", on another (yocto on intel edison) after 128 characters.

This does not happen with the libwebsockets-test-echo, so I assume it is something with cppWebSockets. Any idea?

Using this project in a commercial project

Hi @mnisjk,
I really liked the simplicity of this wrapper and it really solved some of the issues i have been having . Kudos to you and the rest of the contributors!

I was wondering if it is possible to use your project in a commercial project. You specifically mention in LICENSE.md that this is a wrapper around libwebsockets ( which is under lgpl ). So i'm confused whether i can use it in a commercial project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.