Skip to content
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

x/net/websocket: why get the EOF err back ? #23300

Closed
XinhongWu opened this issue Jan 2, 2018 · 1 comment
Closed

x/net/websocket: why get the EOF err back ? #23300

XinhongWu opened this issue Jan 2, 2018 · 1 comment

Comments

@XinhongWu
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.8.3 linux/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build244926751=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

I want to do load-test using JMeter.
I let more than 2000 threads running concurrent while one thread means one request , and I find that many requests fail due to connecting time-out.

My code is as below:
`package main

import (
"golang.org/x/net/websocket"
"fmt"
"log"
"net/http"
)

func webHandler(ws *websocket.Conn) {
msg := make([]byte, 512)
n, err := ws.Read(msg)
if err != nil {
log.Println("ws.read ",err)
}
fmt.Printf("Receive: %s and read len: %d\n", msg[:n], n)

send_msg := string(msg[:n])
m, err := ws.Write([]byte(send_msg))
if err != nil {
	log.Println("ws.write ", err)
}
fmt.Printf("Send: %s\n and write len: %d\n", msg[:m], m)

}

func httpEchoHandler(w http.ResponseWriter, req *http.Request){
s := websocket.Server{Handler: websocket.Handler(webHandler)}
s.ServeHTTP(w, req)
}

func main() {
http.HandleFunc("/echo",httpEchoHandler)

err := http.ListenAndServe(":8080", nil)
if err != nil {
	log.Println("ListenAndServe: " + err.Error())
}else{
	log.Println("start server on port 8080")
}

}`

At the same time, I get log info:
2018/01/02 08:18:01 ws.read then return EOF

Can you help me exxplain Which condition will cause the read EOF error ?

What did you expect to see?

All threads run successfully

What did you see instead?

The log info “EOF ”

@gopherbot gopherbot added this to the Unreleased milestone Jan 2, 2018
@mvdan
Copy link
Member

mvdan commented Jan 2, 2018

I don't see a bug or particular request here, and the issue tracker is only used for those. For questions about Go, see https://golang.org/wiki/Questions.

@mvdan mvdan closed this as completed Jan 2, 2018
@golang golang locked and limited conversation to collaborators Jan 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants