Firstly - is my assumption correct? Is it possible that a race condition could cause the close message to arrive at the server before the last actual message send arrives?
Secondly - is there a way to ask Faye::Websocket to close down gracefully so that it will take care of ensuring all messages have been transmitted to the server before closing the connection? Or do I need to build in some kind of acknowledgement into my protocol? Or some other alternative I haven't considered?
+- +- \----+----/ \-----+------/| | | || | mask message| || +-- 8=masked, 5=length|+----- 8=final, 1=text
(I've just realised that you also need to add logging to the `write(data)` method in `faye-websocket-0.7.2/lib/faye/websocket.rb`, where it turns out I'm needlessly overriding the method from the API module. I'll fix that in the next release.)
On 23 April 2014 23:18, Matt Wynne <matt....@gmail.com> wrote:Firstly - is my assumption correct? Is it possible that a race condition could cause the close message to arrive at the server before the last actual message send arrives?Hi Matt,There shouldn't be a race condition unless you're using the socket from multiple threads.
--
You received this message because you are subscribed to a topic in the Google Groups "Faye users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/faye-users/C9aV8e0ZiKo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to faye-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I think the main thing that your example below helped me to realise is that the bulk of the work needs to be done in the ‘open’ event handler on the client. I had assumed that if I did that I would block the main EventMachine reactor loop, but I guess the `queue.pop` will be giving control back to the reactor loop regularly enough.I’ve now adapted the code to look like this: https://github.com/cucumber-ltd/cucumber-pro-ruby/blob/master/lib/cucumber/pro.rb and I can’t get the race condition to reappear.
On 25 April 2014 10:07, Matt Wynne <matt....@gmail.com> wrote:I think the main thing that your example below helped me to realise is that the bulk of the work needs to be done in the ‘open’ event handler on the client. I had assumed that if I did that I would block the main EventMachine reactor loop, but I guess the `queue.pop` will be giving control back to the reactor loop regularly enough.I’ve now adapted the code to look like this: https://github.com/cucumber-ltd/cucumber-pro-ruby/blob/master/lib/cucumber/pro.rb and I can’t get the race condition to reappear.I would have thought that https://github.com/cucumber-ltd/cucumber-pro-ruby/blob/master/lib/cucumber/pro.rb#L75 would block the event loop, although I'm often surprised at the behaviour of EM stuff.