Hello,
I'm having a problem where a message published on the server is not being received by a client that has subscribed. I have a nodejs server where I subscribe to the channel '/users/read' and I publish to the channel 'users/updated'. I also have a javascript web app where a client publishes to '/users/read' and subscribes to '/users/updated'. My console.log messages tell me that the subscriptions and publishing is being done in the correct order but the client never receives the message. That is, unless I kill the server using Ctrl+C. Then the client receives the message.
Here's the client code
FayeClient.subscribe("/users/updated/user1", function(data) {
console.log('receiving user update: ' + new Date().getTime());
console.log(data);
});
FayeClient.publish("/users/read", {"id":"user1"});
console.log('sent request: ' + new Date().getTime());
Here's the server code
fayeclient.subscribe('/users/read', function(data) {
console.log('received request for user record: ' + new Date().getTime());
fayeclient.publish('/users/updated/user1', {"id": "user1", "name": "user1 name"});
console.log('sent user record: ' + new Date().getTime());
});
I've disabled, websocket using FayeClient.disable('websocket'); in the web app because I use nginx to proxy the call. The website runs at localhost:8080 (
app.test.dev) and the nodejs app runs at localhost:3000 (
app.test.dev/api). Also the nodejs server uses express and faye is attached to that.
I'm not sure if the issue is my coding of the faye subscriptions and publishings or if it is the web server config.
Some additional info:
Here's the console.log output from the server when the app starts
clientid: 1cwd0qy1vjg8hi1kaypf71ey2bv3
subscribed: 1cwd0qy1vjg8hi1kaypf71ey2bv3 : /users/read
When I visit the web app in the browser, the server console.log output is
clientid: 1k5pwpq0aoaige0r1fzuw1w4g9h0
published: 1k5pwpq0aoaige0r1fzuw1w4g9h0 : /users/read
subscribed: 1k5pwpq0aoaige0r1fzuw1w4g9h0 : /users/updated/user1
received request for user record: 1331033657508 (this is a timestamp)
published: 1cwd0qy1vjg8hi1kaypf71ey2bv3 : /users/updated/user1
sent user record: 1331033657510 (this is a timestamp)
The output from in the browsers console is
sent request: 1331033657488 (this is a timestamp)