Coder Social home page Coder Social logo

siddhi-io-websocket's Introduction

Siddhi IO WebSocket

Jenkins Build Status GitHub Release GitHub Release Date GitHub Open Issues GitHub Last Commit License

The siddhi-io-websocket extension is an extension to Siddhi that allows to receive and publish events through WebSocket.

For information on Siddhi and it's features refer Siddhi Documentation.

Downloads

  • Versions 3.x and above with group id io.siddhi.extension.* from here.
  • Versions 2.x and lower with group id org.wso2.extension.siddhi. from here.

Latest API Docs

Latest API Docs is 3.0.3.

Features

  • websocket (Sink)

    A Siddhi application can be configured to publish events via the Websocket transport by adding the @Sink(type = 'websocket') annotation at the top of an event stream definition.

  • websocket-server (Sink)

    A Siddhi application can be configured to run as a websocket server by adding the @Sink(type = 'websocket-server') annotation at the top of an event stream definition.

  • websocket (Source)

    A Siddhi application can be configured to receive events via the WebSocket by adding the @Source(type = 'websocket') annotation at the top of an event stream definition.
    When this is defined the associated stream will receive events from the WebSocket server on the url defined in the system.

  • websocket-server (Source)

    A Siddhi application can be configured to receive events via the WebSocket by adding the @Source(type = 'websocket-server') annotation at the top of an event stream definition.

Dependencies

There are no other dependencies needed for this extension.

Installation

For installing this extension on various siddhi execution environments refer Siddhi documentation section on adding extensions.

Support and Contribution

  • We encourage users to ask questions and get support via StackOverflow, make sure to add the siddhi tag to the issue for better response.
  • If you find any issues related to the extension please report them on the issue tracker.
  • For production support and other contribution related information refer Siddhi Community documentation.

siddhi-io-websocket's People

Contributors

ajanthy avatar anoukh avatar anugayan avatar dilini-muthumala avatar dnwick avatar grainier avatar ketharan avatar maheshika avatar minudika avatar mohanvive avatar nisalaniroshana avatar niveathika avatar pcnfernando avatar ramindu90 avatar sajithshn avatar senthuran16 avatar sivaramya avatar suhothayan avatar sujanan avatar this avatar tishan89 avatar wso2-jenkins-bot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

siddhi-io-websocket's Issues

Support for filtering events published to WebSocket adaptor based on QueryString

Description:
The current implementation of the UIPublisher Adaptor publishes any received event to all currently subscribed WebSocket sessions without any specific filterization.

This improvement suggests the filtering of the received events based on any query strings used during the time of the WebSocket subscription. Hence, the events are matched against these query strings and are delivered only to those relevant session endpoints.

Starting a Siddhi app with an invalid URL in a websocket sink is not aborted, after upgrading to `org.wso2.transport.http:org.wso2.transport.http.netty-6.3.24`

Description:
When there is a websocket sink having an invalid URL in a Siddhi app, it is expected that, the Siddhi app should not successfully start, with an exception. This is being asserted in the following test case:

public void testWebSocketSinkInvalidUri() throws InterruptedException {

When upgrading to org.wso2.transport.http:org.wso2.transport.http.netty-6.3.24 (from 6.0.272), even though a SiddhiAppRuntimeException is thrown, it's not propagated. Instead, it's being caught and logged by io.netty.util.concurrent.DefaultPromise as follows:

[nioEventLoopGroup-58-1] WARN io.netty.util.concurrent.DefaultPromise - An exception was thrown by org.wso2.transport.http.netty.contractimpl.sender.websocket.WebSocketClient$$Lambda$43/876915855.operationComplete()
io.siddhi.core.exception.SiddhiAppRuntimeException: Error while connecting with the websocket server defined in 'io.siddhi.extension.map.xml.sourcemapper.XmlSourceMapper@671f7188'.
        at io.siddhi.extension.io.websocket.source.WebSocketSourceHandshakeListener.onError(WebSocketSourceHandshakeListener.java:50)
        at org.wso2.transport.http.netty.contractimpl.websocket.DefaultClientHandshakeFuture.notifyError(DefaultClientHandshakeFuture.java:64)
        at org.wso2.transport.http.netty.contractimpl.sender.websocket.WebSocketClient.lambda$handshake$0(WebSocketClient.java:112)
        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:577)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:570)
        at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:549)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:490)
        at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
        at io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:608)
        at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:117)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:321)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:337)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:702)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/127.0.0.1:6060
Caused by: java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
        at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:702)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)

It seems that, io.netty.util.concurrent.DefaultPromise is being engaged due to the addition of addListener, which was introduced in wso2/transport-http#364.

websocketserver duplicate send msgs to client

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.