<p>Hey, I'm looking to use fasthttp with websockets, but so far I couldn't find something to work. There's a fork to the gorilla's package, but unfortunately the examples still uses net/http. There's also a fasthttp contrib packages, but got issues. Any help would be appreciated.</p>
<p>I figured it out till the end</p>
<hr/>**评论:**<br/><br/>cenuij: <pre><p>The real solution here, imo, is don't use fasthttp. Then all your issues are not issues anymore.</p></pre>shark1337: <pre><p>That's not how developers solve issues, go face it or or go home.</p></pre>cenuij: <pre><p>I disagree. </p>
<p>My opinion is that fasthttp is too far removed from the consensus around interoperability of HTTP libraries in the Go community. I believe therefore you'll always be chasing some sort of kludge or fix for working around that.</p>
<p>I think you'll find less problems over the lifetime of your project, and save on man hours invested, if you use something else. </p>
<p>There's nothing wrong with stopping to take stock and review the use of one particular library over another, if you find one thing is too annoying or problematic to work with, poorly supported in the ecosystem - swap it out for something else.</p></pre>shark1337: <pre><p>Well, thanks for telling me not to use fasthttp, that really helped me...I've figured it out the issue digging in the source code...</p></pre>itsmontoya: <pre><p>FastHTTP is not a good library. In real world tests stdlib smokes it. My team has spent extensive time benching it in numerous scenarios. FastHTTP is only good for extremely fast responses (EG, hello world)</p></pre>shark1337: <pre><p>For what I need I found it to be the fastest</p></pre>itsmontoya: <pre><p>What do you need? Are you really going to be serving static strings with no lock contention what so ever?</p></pre>ZetaHunter: <pre><p>I use <code>gobwas/ws</code> for my latest ventures in WS domain, you could try that out too, it doesn't use net/http, or fasthttp, instead it lives on its own tcp port, what I do is have API that returns the address and then the WS client uses it.</p></pre>shark1337: <pre><p>Thanks, I'll take a look!</p></pre>recurrency: <pre><p>haven't done much work on ws but wondering: why isn't websockets in the stdlib?</p></pre>cenuij: <pre><p>Websockets were a response to the limitations of HTTP1.x, the standards were changing frequently while Go was being developed so it made no sense to have it in the standard library.</p>
<p>It makes even less sense now that HTTP2 is well supported in Go.</p>
<p>Incidentally it's my understanding that fasthttp also has interoperability issues with HTTP2 and the Go standard library. For most teams and developers this alone would exclude its use from any project.</p></pre>lstokeworth: <pre><p>There's an <a href="https://github.com/gorilla/websocket/issues/252" rel="nofollow">open issue in Gorilla</a> on fasthttp support. The issue is labeled "help wanted".</p></pre>shark1337: <pre><p>Fixed the issue.</p></pre>dlsniper: <pre><p>How? </p></pre>shark1337: <pre><p><a href="https://github.com/fasthttp-contrib/websocket" rel="nofollow">https://github.com/fasthttp-contrib/websocket</a>
or
<a href="https://github.com/leavengood/websocket" rel="nofollow">https://github.com/leavengood/websocket</a></p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传