TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

uWebSockets: Scalable WebSocket server library for Node.js and C++11

108 点作者 alexhultman大约 9 年前

14 条评论

alexhultman大约 9 年前
I want to thank all people involved in making this open source project possible. Things are by far not set in stone and this library has only been in development for about 2 months now.<p>We are working with SocketCluster to make µWS default in version 5, and I have gotten a lot of help from a lot of people during these months.<p>Thanks for support, I will be accepting PR&#x27;s and receiving issues that we need to fix before making any kind of official stable release.<p>Also, try to ignore the hateful comments - these commenters build their cases on thin air, and if you <i>actually</i> do find anything you want to change - I will accept PR&#x27;s that can be shown to improve the library.
Matthias247大约 9 年前
Hey there. Just wrote down a few things that came to my mind after seeing this. Don&#x27;t see it as criticism, but as a few hints&#x2F;remarks what has to be covered by a websocket (or any other protocol) implementation. Imho the high performance part isn&#x27;t too hard to achieve and shouldn&#x27;t be the highest rated. The important thing is that such a server should be rock solid in implementation, otherwise it&#x27;s worthless.<p>Some things that you should answer if you are offering this as a C++ websocket library, and which are currently not covered in the header file:<p><pre><code> - Whats the threading model of the library? - Will server.run() start a singlethreaded eventloop (I guess so from taking a supershort peek into the code and seeing libuv) and everything is running inside there or will it start multiple worker threads? - Based on the last question, from which thread[s] are the other callbacks called. - If multiple threads are used, is the library threadsafe for sending messages from other threads - Is it integratable in other eventloops? Most applications already have a mainloop or something like this, libraries which only work with their own mainloop are not very useful. Normally applications also have to deal with other application logic besides responding to websocket messages. </code></pre> Besides that a few general questions that you should be able to answer for a websocket implementation:<p><pre><code> - What&#x27;s the sending behavior of socket.send? - Will it block until all data was sent? This can cause problems with slow receivers in singlethreaded environments. - Will it copy all data and buffer it internally until it can be sent? This provides no means for backpressure and slow receivers (or non-receivers) can exhaust the servers memory. - Does it handle connection close properly? This is unfortunatly not too easy in websockets. - And are there timers in place for force closing the connection if the shutdown sequence is not completed properly? Or if the initial handshake is not completed in a given timeframe? - Does ist handle control frames? And will it merge control frames (PONGs) if multiple are queued before they are sent? And will it stop sending them after close connection is initiated?</code></pre>
评论 #11739691 未加载
评论 #11739458 未加载
justsaysmthng大约 9 年前
In <a href="https:&#x2F;&#x2F;github.com&#x2F;alexhultman&#x2F;uWebSockets&#x2F;blob&#x2F;master&#x2F;src&#x2F;uWS.cpp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alexhultman&#x2F;uWebSockets&#x2F;blob&#x2F;master&#x2F;src&#x2F;u...</a><p>What&#x27;s the deal with<p>delete [] (char *) head;<p>where `head` is of type `struct Message` ? Is this some kind of performance trick ?... Otherwise it looks kind of suspicious..
评论 #11738139 未加载
评论 #11737669 未加载
msim大约 9 年前
It&#x27;s code like this that gives C++ a bad reputation. It&#x27;s not modern in any sense. Compiling it with my default warning level in clang gives 482 warnings! Here&#x27;s a summary:<p><pre><code> warning: cast from &#x27;...&#x27; to &#x27;...&#x27; increases required alignment from 1 to X [-Wcast-align] warning: declaration shadows a field of &#x27;...&#x27; [-Wshadow] warning: declaration shadows a local variable [-Wshadow] warning: implicit conversion changes signedness: &#x27;...&#x27; to &#x27;...&#x27; [-Wsign-conversion] warning: implicit conversion loses integer precision: &#x27;...&#x27; to &#x27;...&#x27; [-Wconversion] warning: implicit conversion loses integer precision: &#x27;...&#x27; to &#x27;...&#x27; [-Wshorten-64-to-32] warning: macro name is a reserved identifier [-Wreserved-id-macro] warning: no previous prototype for function &#x27;...&#x27; [-Wmissing-prototypes] warning: operand of ? changes signedness: &#x27;int&#x27; to &#x27;char&#x27; [-Wsign-conversion] warning: unused parameter &#x27;...&#x27; [-Wunused-parameter] warning: use of old-style cast [-Wold-style-cast] </code></pre> Use with caution!
评论 #11739498 未加载
评论 #11739420 未加载
kapouer大约 9 年前
I&#x27;m already using it on a socket.io production server. Super-stable for days, and noticeably less cpu &#x2F; memory usage. Great open source software !
评论 #11737590 未加载
samsonradu大约 9 年前
I&#x27;m currently using the `ws` library for a custom live-streaming solution (broadcasting binary data) and the memory&#x2F;CPU usage is indeed not small for a handful of clients. What does `uws` bring new (technically) to the table?
评论 #11737313 未加载
评论 #11737344 未加载
moron4hire大约 9 年前
You say you support Windows, but when I try to use it, it gives me an error<p><pre><code> Error: Compilation of µWebSockets has failed and there is no pre-compiled binary available for your system. Please install a supported C++ compiler and reinstall the module &#x27;uws&#x27;. </code></pre> A) Which are the supported compilers?<p>B) This issue makes it seem like that wouldn&#x27;t matter, anyway? <a href="https:&#x2F;&#x2F;github.com&#x2F;alexhultman&#x2F;uWebSockets&#x2F;issues&#x2F;72" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alexhultman&#x2F;uWebSockets&#x2F;issues&#x2F;72</a>
jondubois大约 9 年前
uWebSockets is bundled as part of SocketCluster <a href="http:&#x2F;&#x2F;socketcluster.io&#x2F;" rel="nofollow">http:&#x2F;&#x2F;socketcluster.io&#x2F;</a> and we plan to make it the default in SC v5. We got a massive speedup! Highly recommended.
评论 #11738075 未加载
est大约 9 年前
Anything similar in Python?<p>Currently using pypy+tornado-sockjs. Works OK.
评论 #11737279 未加载
评论 #11737333 未加载
评论 #11737213 未加载
dhendo大约 9 年前
I&#x27;m assuming it&#x27;s not a straight swap for the `websocket` package? <a href="https:&#x2F;&#x2F;github.com&#x2F;theturtle32&#x2F;WebSocket-Node" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;theturtle32&#x2F;WebSocket-Node</a>
评论 #11738244 未加载
meir_yanovich大约 9 年前
What is the main difference between libwebsockets and this ?<p>can it be embedded in to libuv? in C
评论 #11749375 未加载
throwaway2016a大约 9 年前
This looks awesome. Can I use this with Meteor? If there is any app that would benefit from websocket optimizations it&#x27;s Meteor.
评论 #11738261 未加载
lpinca大约 9 年前
The project is young but looks promising.
zkhalique大约 9 年前
Why is your username green?
评论 #11739277 未加载