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

Cannot tested ws server on GO #57

Open
Shkarbatov opened this issue Aug 31, 2018 · 0 comments
Open

Cannot tested ws server on GO #57

Shkarbatov opened this issue Aug 31, 2018 · 0 comments

Comments

@Shkarbatov
Copy link

Hi all!

Run ws server on GO:

package main

import (
	"net/http"

	"github.com/gobwas/ws"
	"github.com/gobwas/ws/wsutil"
)

func main() {
	http.ListenAndServe(":4375", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		conn, _, _, err := ws.UpgradeHTTP(r, w)
		if err != nil {
			// handle error
		}
		go func() {
			defer conn.Close()

			for {
				msg, op, err := wsutil.ReadClientData(conn)
				if err != nil {
					// handle error
				}
				err = wsutil.WriteServerMessage(conn, op, msg)
				if err != nil {
					// handle error
				}
			}
		}()
	}))
}

And then run test:

thor --amount 100 ws://curex.ll:4375/

Thor:                                                  version: 1.0.0

God of Thunder, son of Odin and smasher of WebSockets!

Thou shall:
- Spawn 4 workers.
- Create all the concurrent/parallel connections.
- Smash 100 connections with the mighty Mjölnir.

The answers you seek shall be yours, once I claim what is mine.

Connecting to ws://curex.ll:4375/
                     
Online               152 milliseconds
Time taken           174 milliseconds
Connected            100
Disconnected         0
Failed               100
Total transferred    0B
Total received       0B

Durations (ms):

                     min     mean     stddev  median max    
Handshaking          15      28            7      25 48     
Latency              NaN     NaN         NaN     NaN NaN    

Percentile (ms):

                      50%     66%     75%     80%     90%     95%     98%     98%    100%   
Handshaking          25      27      32      33      40      44      47      48      48     
Latency              NaN     NaN     NaN     NaN     NaN     NaN     NaN     NaN     NaN    

Received errors:

100x                 continuation frame cannot follow current opcode

But receive an error:

Failed 100

WS server works it's for shure. I tested him with client:

<script>
    var ws = new WebSocket('ws://curex.ll:4375/');
    ws.onmessage = function(evt) { alert(evt.data); };
    ws.onopen = function (event) { ws.send('test!'); }
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant