sta / websocket-sharp

A C# implementation of the WebSocket protocol client and server
http://sta.github.io/websocket-sharp
MIT License
5.69k stars 1.66k forks source link

send("message") inside onopen() always fail #687

Open hy-net opened 2 years ago

hy-net commented 2 years ago

Using javascript to invoke a WSSharp server

var ws = new WebSocket("ws://localhost:5002/test");
ws.onopen = function () {
    setTimeout(function () {
        ws.send("Hello");
    }, 1000);
};

The above code will fail if I do not wrap ws.send() with setTimeout()