-
Notifications
You must be signed in to change notification settings - Fork 381
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
wss:// and netpoll #121
Comments
I get the same issue using tls.Server and then upgrading as said in #64 |
I have the same issue with or without TLS... if i send 10/15 messages, the server picks up the first 7/8... then if i send some more messages, it gives me the previous missed messages. Does anyone have any idea why ? I have similar set up to the original issue taken from the example modified a bit. |
@IbrahimKoutabli have you tried checking TCPConn.SetNoDelay? |
@navossoc on the server or client? i tried wrapping the server conn with SetNoDelay to no avail... any advice? thanks |
because it defaults to true ? already no delay |
For better results: on both sides, so you can make sure that you doesn't buffer. Are you using any kind of proxy/reverse proxy/cdn? I'm using the If you are using a |
Thanks I haven't deployed it yet so I'm not using any proxies, I'm just running it locally. I'm using a So if it defaults to true (I manually set it to true anyway) why do all the messages sent to the server not being processed ? |
|
something to do with the poller ? |
SetNoDelay should not affect the protocol logic of the application layer |
Which package does "netpoll" refer to? |
@lesismal netpoll is from github.com/mailru/easygo |
netpoll.HandelRead called the conn.File() which returns a File with the duped fd, I guess you use the previous safeConn in user.Receive(), but the netpoll is handling the duped one. |
All the above example does not show the complete code. According to your guys' description, I guess it is due to the problem of tcp sticky package: |
I check the code, you should not use netpoll with gobwas, Upgrade may block: https://github.com/gobwas/ws/blob/master/server.go#L452 if many connections send bytes one-by-one or send a half ws upgrade message, it will make all your gopool's task blocked, then your service not available. and refer to this: When using epoll somehow wsutil helpers is not the best way to deal with frames. for epoll/1m-ws-connections, you may try this: poller-ws-server |
@macabre2077 easygo/netpoll default use epoll ET model. You can change to epoll LT model. LT and ET model all will trigger read event of one fd concurrency, if you don't want to do something locking to ensure read order, you can use EPOLLONESHOT. Code snippets: desc := netpoll.Must(netpoll.HandleReadOnce(conn))
// Subscribe to events about conn.
poller.Start(desc, func(ev netpoll.Event) {
if ev&(netpoll.EventReadHup|netpoll.EventHup) != 0 {
poller.Stop(desc)
chat.Remove(user)
return
}
pool.Schedule(func() {
if err := user.Receive(); err != nil {
// When receive failed, we can only disconnect broken
// connection and stop to receive events about it.
poller.Stop(desc)
chat.Remove(user)
return
}
// oneshot model should do resume after every read operation
poller.Resume(desc)
})
}) |
It is not suitable to use netpoll in gobwas, epoll relies on non-blocking fd, but the upgrade of gobwas relies on blocking fd, the upgrade will cause the task pool goroutine to block |
Many people do not understand the relationship between synchronization, asynchrony, and task pool. Similar problems exist in this 1m-go-websockets. |
@lesismal by design of this library you should upgrade first before registering your connection in epoll. Otherwise you have to implement something like pico http parser from C world. I believe that probably would be overkill. |
so I write this real-epoll-http/ws, and examples |
I was having issues with my app and found out that using wss:// with nginx as a proxy leads to missing messages. I am using the chat example with netpoll.
Running the golang code below with
ws://
returns the number of sent requests, whilst usingwss://
returns only first 2-3 messages.High-level example with wsutil works as expected, I think that might be the issue with netpoll.
Hopefully, that makes more sense to you. Thanks
slightly modified chat example from gobwas/ws-examples
server.go
client.js
Nginx config
The text was updated successfully, but these errors were encountered: