0

I want to create an Event Publisher that connect via Websocket. When I try to connect it with my simple socket io server, the url is

 ws://localhost:3000/socket.io/

It didn't receive the stream..

I've set the inline format for the stream like this :

42["input-message",{"LAT":{{latitude}},"LON":{{longitude}}}]
Community
  • 1
  • 1
Faruk
  • 5,438
  • 3
  • 30
  • 46

2 Answers2

1

If I understand your question correctly,

  • you do not get any errors when the event is published from the CEP server
  • but the socket io server does not show any indication that it received the event either.

CEP server showing no error logs means:

  • CEP server is successfully connected to the socket io server. (if the connection is dropped, then you should see an error log, and CEP will try to reconnect)
  • Probably the event was sent to socket io server by Websocket publisher (or the Websocket publisher did not recieve any event at all to be sent to socket io server)
    • (When you send an event, if the CEP server cannot parse the event, then also you should see an error log.)

Here are some points which might help you to troubleshoot the issue:

  1. Enable tracing in your websocket publisher (You may refer to this 'Event Tracer' doc). Then send an event and check the traces. This will allow you to verify whether the Websocket publisher recieved the event.
  2. If there are traces shown for the publisher, but still no event received at the socket io server, then it could be that some error occurs at socket io server, and the exception is not logged (might have being swallowed).

Hope this will help.

Dilini
  • 777
  • 8
  • 22
  • I think the problem is not in wso2cep, but in the socket.io. Because Socket io using session to distinguish between each connection. Therefore one of the solution is to create new websocket that connect the event publisher with the socket.io – Faruk Oct 12 '15 at 07:13
0

Because I cannot directly connect to the socket.io, thus I created a simple websocket that act as a middleware that sending the input from WSO2CEP into the socket.io

var io = require('socket.io').listen(server);
io.set('origins', '*:*');

var WebSocketServer = require('ws').Server, 
   wss = new WebSocketServer({ port: 8087 })

//wss sending every message that it received to the socket.io
wss.on('connection', function connection(ws) {
  console.log('a WSO2CEP-PUBLISHER is connected');
  ws.on('message', function incoming(message) {
    console.log('received: %s', message);
    io.emit('input-message', JSON.parse(message));
  });
});

notice that, the data that come from event publisher is string formatted, so if needed to send it as a JSON object, than use JSON.parse() function.

Faruk
  • 5,438
  • 3
  • 30
  • 46