New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add minimal WebSocket server implementation for evhttp #1322
Conversation
Thank you! This is a great feature! Do you have some performance numbers for websocket server? No we have stable CI. So could you please fix building
|
I've tried to fix all issues I found, but still stuck with proper unit tests. Could you give me a direction to use them right (internal libevent's kitchen is new for me)? I added two cases: when bad handshake is provided and a regular WS data exchange. After I read out all headers in |
Maybe this will help? https://github.com/libevent/libevent/pull/1322/files#r947026444 |
I just skipped including new testes for making all CI process pass (after adding includes for Windows and FreeBSD systems) and now going to revert it. But in the current state WS tests will not pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM.
Just some minor comments, after they will be addressed I will be happy to merge!
And a minor thing, can you please squash all commits into one and write some descriptions about design decisions that had been made.
event_warn("%s: unexpected frame type %d\n", __func__, type); | ||
evws_force_disconnect_(evws); | ||
} | ||
evbuffer_drain(input, msg_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be done in case of incomplete frames?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete frames will not pass through here because of continue
operator which do next iteration for the loop
@widgetii many thanks for you contribution! |
Tor fails to build with this .
|
There are two options:
@azat What do you think is better? |
Let's just rename bundled. |
This is fixed in master. |
I'd suggest the |
The name of And, for the function header[pos++] = (unsigned char)frame_type | 0x80; /* fin */ It should be And, there is no response for ping / pong. Response for pong is useless, however, Response to ping should be handled. BTW, I use |
This PR was merged more than 1,5 years ago and some changes were done on top of it (like differentiations between text and binary data) If you have any improvements to the code, fell free to open new PR |
This adds few functions to use evhttp-based webserver to handle incoming WebSockets connections. We've tried to use both libevent and libwebsockets in our application, but found that we need to have different ports at the same time to handle standard HTTP and WebSockets traffic. This change can help to stick only with libevent library.
Implementation was inspired by modified Libevent source code in ipush project.
Also, WebSocket-based chat server was added as a sample.