-
Notifications
You must be signed in to change notification settings - Fork 378
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
EOF error on ws.Upgrade #153
Comments
This issue maybe relates to tcp config,check somaxconn size and fd size in your environment. |
somaxconn:
It seems that messages are cut off when reading from connection, for example:
Each message is 512 bytes-long. Can I ask for a guide, what are the other settings I should check? |
Try to use http server,like Readme shows,because websocket bases on http 1.1or above version not tcp.
c in code is *gin.Context |
Thank you, I will give it a try. The server I posted above is from README "The lower-level example without wsutil" example. I wonder if the example from README is sufficient to handle mentioned a million websockets connections. |
Sorry,I didn't notice that example,maybe lower-level only supports pure url without parameters? |
Unfortunately, I think Server: package main
import (
"fmt"
"net"
"github.com/gobwas/ws"
)
func main() {
ln, err := net.Listen("tcp", ":8111")
if err != nil {
panic(err)
}
for {
conn, err := ln.Accept()
if err != nil {
fmt.Println("accept err", err)
continue
}
_, err = ws.Upgrade(conn)
if err != nil {
fmt.Println("upgrade", err)
}
}
} client: package main
import (
"context"
"fmt"
"sync"
"time"
"github.com/gorilla/websocket"
)
func main() {
var wg sync.WaitGroup
for i := 0; i < 1000; i++ {
wg.Add(1)
go func() {
defer wg.Done()
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
defer cancel()
_, _, err := websocket.DefaultDialer.DialContext(ctx, "ws://localhost:8111", nil)
if err != nil {
fmt.Println(err)
}
}()
}
wg.Wait()
} There are no params in URL, but I receive upgrade EOF. For some reason, this method returns EOF: https://github.com/gobwas/ws/blob/master/util.go#L169. This is non-deterministic. I have to run client code few times to observe EOF error |
这个情况确实是必现的。因为你的client在链接建立后,就自己销毁了。 相当于客户端主动断开链接。 |
I'm having similar issue - reading from web socket server returns EOF... consistently |
I receive
EOF
error onws.Upgrade
during high load on a server. I took code from example and run ~2k concurrent connections to websocket server. Another thing is that I pass JWT token in URL.It seems that
readLine
insideUpgrade
is causing error: https://github.com/gobwas/ws/blob/master/server.go#L452and then error is returned from here: https://github.com/gobwas/ws/blob/master/util.go#L183
Example code to reproduce the issue:
Server:
client:
The text was updated successfully, but these errors were encountered: