How to hit the WebSocket Endpoint?

后端 未结 6 1314
梦如初夏
梦如初夏 2021-02-05 22:52

I see that there is websocket endpoint which works out fins with Java tests. In logs I see

Connecting to: ws://127.0.0.1:8080/76f48a44-0af8-444c-ba97-3f1ed34af         


        
6条回答
  •  萌比男神i
    2021-02-05 23:30

    If you mean literally to test the implementation of websockets, I found Autobahn's test suite to be very useful: http://autobahn.ws/

    If you just want to noodle with a websocket I would recommend using the developer tools in a browser like chrome to make a connection and send/recv data:

    var ws = new WebSocket("ws://127.0.0.1:8080/76f48a44-0af8-444c-ba97-3f1ed34afc91/tweets");
    ws.onclose = function() { // thing to do on close
    };
    ws.onerror = function() { // thing to do on error
    };
    ws.onmessage = function() { // thing to do on message
    };
    ws.onopen = function() { // thing to do on open
    };
    ws.send("Hello World");
    

提交回复
热议问题