siddhi-io/siddhi-io-websocket

websocketserver duplicate send msgs to client

Closed this issue · 0 comments

sql:
'@info(name = "query1") @source(type="websocket-server", host="192.168.21.11", port="8081", @Map(type="json")) define stream sourceStream (symbol string); @info(name = "query2") @sink(type="websocket-server", host="192.168.21.11", port="8082", @Map(type="json")) define stream sinkStream (symbol string); from sourceStream select * insert into sinkStream;'

js:
function connect_ws_socket(websocketserver_src, websocketserver_dst)
{
if (websocketserver_src != "") {
ws_src = connect_ws(websocketserver_src);
}
if (websocketserver_dst != "") {
ws_dst = connect_ws(websocketserver_dst);
}

    ws_src.addEventListener('open', function () {
            window.clearInterval(timerid);
            var src_datas = new Array();
            src_datas = src_data.split("\n")
    console.log("src datas length: " + src_datas.length)
    //      for (i = 0; i < src_datas.length; i ++) {
            send_ws_data(src_datas[0])
    console.log("src datas xx: " +i + " " + src_datas[i])

    //      }
    });

}

function recv_ws_data(ws_data)
{
dst_data += ws_data

    console.log("recv ws_data"+ ws_data)

    console.log("dst value" + document.getElementById("dst").value)

    document.getElementById("dst").value=dst_data;

}

packet to port 8081, only has 1 packet, but port 8082 returns too many packets, tcpdump file :

8081.txt
8082.txt

github can't upload .cap file, I rename to .txt, you should reanme to .cap and use wireshark open 8081.cap and 8082.cap

websocket packets order like this:
client server
send {"event":{"symbol": "a"}} ----->
recv {"event":{"symbol": "a"}} <------

send        {"event":{"symbol": "bb"}}  ----->
     recv 	{"event":{"symbol": "bb"}} <------
     recv 	{"event":{"symbol": "bb"}} <------

send        {"event":{"symbol": "cc"}} ----->
     recv 	{"event":{"symbol": "cc"}}<------
     recv 	{"event":{"symbol": "cc"}}<------
     recv 	{"event":{"symbol": "cc"}}<------

send        {"event":{"symbol": "dd"}} ----->
     recv 	{"event":{"symbol": "dd"}}<------
     recv 	{"event":{"symbol": "dd"}}<------
     recv 	{"event":{"symbol": "dd"}}<------
     recv 	{"event":{"symbol": "dd"}}<------

send        {"event":{"symbol": "eee"}} ----->
     recv 	{"event":{"symbol": "eee"}}<------
     recv 	{"event":{"symbol": "eee"}}<------
     recv 	{"event":{"symbol": "eee"}}<------
     recv 	{"event":{"symbol": "eee"}}<------
     recv 	{"event":{"symbol": "eee"}}<------

send        {"event":{"symbol": "fff"}} ----->
     recv 	{"event":{"symbol": "fff"}}<------
     recv 	{"event":{"symbol": "fff"}}<------
     recv 	{"event":{"symbol": "fff"}}<------
     recv 	{"event":{"symbol": "fff"}}<------
     recv 	{"event":{"symbol": "fff"}}<------
     recv 	{"event":{"symbol": "fff"}}<------

just too packets recv. why not one packet recv ?

thx