-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
[FEATURE REQUEST] export more events and authentication #4
Comments
@roytan883 for authentication please see #1229 @kataras But in my opinion, some events need to be authentication, not all events @roytan883 You have access to the total connection count with Server.GetTotalConnections() @roytan883 you have access to CONNECT , Close , and ... for each connection for example
or or |
@majidbigdeli 1, OK, i found 3, #1229 seems work for auth. 2, but how to broadcast PING ? |
@roytan883 for send png to clients I use
I create byte array and then send to client
|
@majidbigdeli Thanks for reply, but actually i'm asking websocket I found
|
@roytan883 yes .
when Message.To is null message brodacast to all clients |
|
yes. it is true |
@majidbigdeli For example: total readTimeout-> 1, set normal connection readTimeout is Normally the client should send So may need Conn struct add those methods:
|
neffos have SetTimeouts func for example https://github.com/kataras/neffos/blob/master/_examples/struct-handler/main.go
|
it is good feature |
if this function not close the socket, seems can be add here. Maybe I can send a PR for this.
|
Hello @roytan883, as I see you, with some help of @majidbigdeli, found the answers in all of your requests/questions except the broadcast websocket PING special message and set timeouts on runtime. Please answer my questions below so I can introduce a feature that will be helpful for you and others.
You can already set them with neffos.WithTimeout or through upgrader/dialer underline implementation.
You pointed out correctly the
Also, @majidbigdeli, about:
These functions these are designed to give statistics and not to handle common operations, each time you call one of those the whole server blocks and can't accept a new connection(except the Thanks |
@kataras after try to implement
is a good idea, also i can implement ACTIVE event here sending to my app layer. |
Yes, exactly, so you see how modular is neffos, you can create new or wrap an existing compatible upgrader/dialer. For example on kataras/iris, to keep the |
You can push a PR when you done with this @roytan883, just note that if your changes have any performance cost create a new file, named wrapper or anything you want and push them on their directories neffos/gobwas and neffos/gorilla in order to be optional to used in top of their original implementations. Keep me updated to help you out with designing! Thanks for using neffos man |
@kataras BTW, I found that MUST reset
|
@roytan883 So you made a total new subpacke for var twServer/twDialer = timingwheel.NewTimingWheel(time.Millisecond, 20) and use it inside Socket. I saw the PR and it does contain a lot of duplications of existing neffos code, I will push changes later on so you can see how u can adapt that to existings upgraders and dialer, tell me when its ready. Thanks a kot. |
About deadline, gorilla, ehich has s setting for it, does not reset it to 0 when write is done, also I dont think itmust reset to 0 because on the next call it will reset it self to the value(except if te value changes to 0, sre you refering to that case?). Setting twice the deadline in the same write/read op is not acceptable, there is another solution to clear the deadline: check if deadline value was >0 and if current value is 0 and then set it to 0 else set, on beginning once not in the end |
@kataras you can try my PR, in the example code, if not reset the deadline to zero, it will receive EOF at It looks strange, why after add those code:
socket never got I test 1 server with 10000 client, works great. But the server take |
Yes, if you run it from About the PR, tell me when you test every case, and complete your changes and etc. and I will push my own changes to your PR so we can work together, because it doesn't need to live on other subpackage with code duplications from existing packages, and for the deadlines, you mean you never got EOF so the Line 102 in f63a528
Thanks @roytan883 |
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 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, 3, for deadline, yesterday when i implement reproduce it is simple, just disable
and add some |
after optimize
CPU and memory looks good now, 10K clients use 240MB on server, and CPU nearly 0% |
Is 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
The text was updated successfully, but these errors were encountered: