Skip to content

Cannot tested ws server on GO #57

Description

@Shkarbatov

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions