wamp.io icon indicating copy to clipboard operation
wamp.io copied to clipboard

lib/server.js problem

Open Kenzku opened this issue 12 years ago • 6 comments

When (in examples/pubsub/server.js)

51    app.publish(topicUri, event);

is being called, it seems the following codes could not be initialised,

(lib/server.js)

function Server(options) {
  this.options = options || {};
  this.topics = {};
  this.clients = {};
}

because, at line 108 (lib/server.js)

if (this.topics[topicUri]) 

where this is still empty: Screen Shot 2013-03-04 at 12 19 27

Thus, the if condition is always false.

Is there any instruction how to use server.js in lib/server.js?

Kenzku avatar Mar 04 '13 10:03 Kenzku

Do you have any subscribers connected to the server?

Server.topics should be set by the "subscribe" handler (handlers.js:70) if (and only if) a client subscribes the topic. When you publish a message through the HTTP interface ("/hub") and no client is subscribed (via a WAMP client), the message is discarded.

nicokaiser avatar Mar 04 '13 10:03 nicokaiser

I just tried to use the example given by Autobahn.js, http://autobahn.ws/js/getstarted and running your server

node server.js

Then I run the client side example on a web browser It says, the server does not speak WAMP

Here is the screenshot, Screen Shot 2013-03-04 at 14 39 31

The client, connect to the server at port 9000

var wsuri = "ws://localhost:9000";

while your server

15 var ws = wsio.listen(9000);
...
61 api.listen(9090);

Is there anything I should do to trigger the WAMP on your server?

Kenzku avatar Mar 04 '13 12:03 Kenzku

i'm having this same issue

bomsy avatar Jun 25 '13 13:06 bomsy

This may(!) be a problem of ws not supporting the protocol header of WebSocket. I have to test this.

nicokaiser avatar Jun 25 '13 15:06 nicokaiser

I tried the example (although with the ws module instead of websocket.io). I'll try with websocket.io soon, however I prefer ws.

https://gist.github.com/nicokaiser/5859603

nicokaiser avatar Jun 25 '13 15:06 nicokaiser

it works. thanks

bomsy avatar Jun 25 '13 16:06 bomsy