FayeCpp
FayeCpp copied to clipboard
Client waits for the next timeout before connecting/subscribing
I have the feeling I don't understand anything about how this Faye business works. I don't have any issues with the javascript clients, but the FayeCpp client does things that I do not understand clearly.
I have a timeout of 30 seconds on my Faye server.
If I don't do anything in the 30 seconds that follow the transport connection, it will timeout, and I'll have to reconnect on my own if I want to do further operations. That's exactly what I expect, nothing strange here.
However, if I do something in the 30 seconds that follow the transport connection, it won't execute immediately: it will wait until those 30 seconds are over, then it will execute these operations (publishing, subscribing, receiving, etc) all at once, and the transport won't be timed out (which mean I can publish something else, but again, I'll have to wait 30 more seconds before the message actually gets published to the faye server).
Do I have to wake up FayeCpp's thread on my own ? Is it sleeping for the duration of the timeout ? I have no idea what's happening to me, but that's my best guess for now.
I can reduce the timeout to 1 second, but that doesn't really fix the problem: a great deal of the messages I publish never reach their destinations when the timeout is 1 second. With the 30 seconds timeout, they all reach their destinations, but only once every 30 seconds.
This is the code of my faye server:
var http = require('http'),
faye = require('faye');
var server = http.createServer(),
bayeux = new faye.NodeAdapter({mount: '/', timeout: 30});
bayeux.attach(server);
server.listen(9292);