Giter Club home page Giter Club logo

Comments (4)

kataras avatar kataras commented on August 22, 2024

The server-side is correct, if you have the "name" filled, but where's your client-side source code?

from examples.

XinhongWu avatar XinhongWu commented on August 22, 2024

@kataras thanks for your reply.
The client is JMeter, and the message is sent in the general way.
If the server code is using the origin go websocket, the message from JMeter can be received.
The server 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.Fatal(err)
}
fmt.Printf("Receive: %s\n", msg[:n])

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

}

func main() {
http.HandleFunc("/echo",
func (w http.ResponseWriter, req *http.Request) {
s := websocket.Server{Handler: websocket.Handler(webHandler)}
s.ServeHTTP(w, req)
});

err := http.ListenAndServe(":8080", nil)

if err != nil {
	panic("ListenAndServe: " + err.Error())
}

}`

Is Iris having the similar function like ws.Read() ?
If so then I can get message under Iris framework

from examples.

kataras avatar kataras commented on August 22, 2024

There is an example for the golang.org/x/net/websocket as client-side talks to an Iris websocket server; https://github.com/iris-contrib/examples/blob/master/websocket/custom-go-client/main.go#L47

from examples.

XinhongWu avatar XinhongWu commented on August 22, 2024

@kataras Thanks very much
I have solved the problem using the golang.org/x/net/websocket as the server.
JMeter can recognize the websocket server using the origin go-websocket.

from examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.