Comments (13)
感谢关注!
不支持fasthttp系的,以前想支持fasthttp但因为fasthttp相关的类型字段没有导出,而且fasthttp基于兼容性、没法修改相关:
valyala/fasthttp#1239
而且就性能来说,不管是基于fasthttp系还是基于标准库,Upgrade后、Conn都是被websocket接管、读写和逻辑都是由websocket库本身处理的了,所以后续的性能与fasthttp或者标准库已经无关了。
倒是可以修改websocket一些内容、单独package去支持fasthttp系的,但是无法有效利用nbio的更多功能、比如不同的IO模式的优势:
https://github.com/lesismal/nbio/releases/tag/v1.3.5
所以修改的意愿不是特别强,我过阵子不忙了看下大概要修改多少,如果修改不大,也可以考虑单开个repo去支持fasthttp websocket
from nbio.
如果你们的websocket是单独的服务、没有与http接口用同一个服务,直接用nbio的就可以了,如果是与http接口一起的,我再想能不能Hijack的方式hack一下,但是需要业务自己去处理一部分Upgrade逻辑,代码也是不太美观
from nbio.
from nbio.
这是fasthttp基于gorilla改造的基于fasthttp的,fiber只要拿到fasthttp.RequestCtx应该就可以直接用了:
https://github.com/fasthttp/websocket
fibber的请求转换为net/http我还没试过,ws这块主要是Upgrade流程+接管conn就可以了
from nbio.
看了下,fasthttp Upgrade直接回调把conn传递给用户的handler了,所以好像可以搞:
https://github.com/fasthttp/websocket/blob/417207d494e8a883b46ae3193fce4c6e9c3d80d5/server_fasthttp.go#L184
from nbio.
from nbio.
看了下,fasthttp Upgrade直接回调把conn传递给用户的handler了,所以好像可以搞: https://github.com/fasthttp/websocket/blob/417207d494e8a883b46ae3193fce4c6e9c3d80d5/server_fasthttp.go#L184
nbio的想精简还是要做下单**剪。直接从 fasthttp/websocket的Upgrade后的Conn里取出conn给nbio的websocket用也可以,类似这里:
#240 (comment)
但是多整了一道就有点别扭
from nbio.
如果转换器ok,那应该就可以,这个adaptor我收藏了,感谢,哈哈哈
咱试试这个转换器能不能拉通
from nbio.
from nbio.
试了下,好像是不行,这个adaptor、fasthttp没有实现 http.Hijacker:
2023/02/25 22:16:35 Upgrade failed: websocket: response does not implement http.Hijacker
from nbio.
如果想省事,可以直接用这个:
https://github.com/fasthttp/websocket
from nbio.
感谢您的回复
这个demo符合我的基本需求 略微改了改 搞定了.
https://github.com/gofiber/recipes/tree/master/websocket-chat
from nbio.
好的,它这个就是用的 github.com/fasthttp/websocket ,在gorilla基础上改的,够用了
from nbio.
Related Issues (20)
- nbio实现网关的一些问题 HOT 9
- custom Logger HOT 43
- Does this library take an advantage of zero-copy upgrade in Websocket? HOT 25
- Reduce the number of calls to time.Now in setdeadline HOT 9
- WebSocket 服务器使用IOModMixed,client正常关闭,OnClose里的err不为nil HOT 36
- Using nbhttp for server-sent events HOT 7
- Use cases of MaxLoad and MaxBlockingOnline configurations HOT 14
- 请教几个参数的问题 HOT 6
- What happens when multiple goroutines send a message to single websocket connection? HOT 16
- 日志打印建议 HOT 3
- Question: writeBuffer HOT 7
- ondata HOT 2
- what's the config of LockPoller and LockPoller use for ? HOT 1
- wss的发包问题 HOT 5
- wss运行一段时间后无法关闭 HOT 21
- export uniqueId from websocket.Conn HOT 5
- 求助:nbio + gin,下载不了文件? HOT 15
- Windows: Based on std net, for debugging only,请问这是表明在windows下不能用嘛?我们的程序是在windows下运行的 HOT 7
- ResetPollerEvent HOT 3
- taskpool 可否延迟回收? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nbio.