[FEATURE REQUEST] export more events and authentication
See original GitHub issueIs your feature request related to a problem? Please describe.
1, I tried neffos, it works great, but seems it only focused on Message
event. But for app layer, maybe want to collect some information about: connection count, each connection startTime and endTime, last activeTime, and so on.
2, send broadcast PING from server to all client. For mobile network, APP may hibernate at background, which can’t send PING. so need server to send PING to remain the TCP connection and APP alive.
3, able to do authentication when websockt upgrade, like pass the http.Request and return a simple true or false. so the app layer can read url and param from http.Request. for example: http://xxxx/ws/endpoint?uid=aaa&token=bbb
Describe the solution you’d like 1, export some event for each connection, like: CONNECT, CLOSE, ACTIVE(stand for: message, ping, pong) …
2, able to broadcast PING
3, export handler for authentication, which default return true
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:23 (6 by maintainers)
Top GitHub Comments
after optimize
timingwheel
to:CPU and memory looks good now, 10K clients use 240MB on server, and CPU nearly 0%
@kataras
1, for this PR, only about keepalive feature. what test case should i write? I create it by a new gobwasalive is trying to not impact old code as i’m not familiar with neffos structure right now. And i already add a example at
_examples/gobwasalive/main.go
. yes, i think some part of it is silly, like theidleTime
byNewDialer/NewUpgrader
and the globaltimingwheel
. I have not wrote any GO code few months, some part of GO is hazy for me.But i think the idea about Keepalive is good, i’m happy that you modify this PR or just implement yours which may much better than this one. Most I care is that server will send PING before timeout, it is very important at mobile network to keep my APP socket alive.
2,
neffos/gobwas/socket.go
return ioutil.ReadAll(s.reader)
works fine. I saynever got EOF
is just about the writing PING and receive EOF error. Normal read return EOF still work (which i use CTRL+C to close client).3, for deadline, yesterday when i implement
two-phases-timeout
by modify the gobwas/gorilla socket.go, both got EOF after PING. gorilla is worse, it got EOF right after send PING; gobwas can send a few PING beforeEOF at neffos.WithTimeout{ WriteTimeout: 20 * time.Second
. I guest both related to the writeDeadline reset issue.reproduce it is simple, just disable
and add some
Printf
ingobwasalive/socket.go ReadData
, then run_examples/gobwasalive/main.go
. you will find that client will disconnect at 20s by EOF.