On 11 June 2012 09:55, Marek Majkowski <span dir="ltr"><<a href="mailto:majek04@gmail.com" target="_blank">majek04@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm afraid there is no "proper" way. When it works - great. But on<br>
network errors, I'd assume the state of the channel is undefined.<br>
I would be surprised if there is a sane way to recover. Best solution<br>
IMO is to kill the channel and establish a new one.<br></blockquote><div><br>I don't think it's actually so bad in principle, though the implementation isn't there yet.<br><br>The channel object on the server side has a timeout - if there's a waiting longpoll, the timer isn't counting down, but during periods when the object is untouched the timer is ticking. The timer is reset to its starting value whenever the object receives a method call. Eventually, if left alone, the channel's timer expires and the channel is closed.<br>
<br>So, if you can arrange for the JS to just attempt reconnection over and over up to the point where the timer must have expired, you can rejoin your channel state. (It works this way because of the spotty nature of XHR "connections" in the best case.) You can control the expiry timer length on the channel object - pass the channelTimeout option (in <i>seconds</i>) to the RabbitMQ.Channel constructor from rabbitmq.js.<br>
<br>If the channel timer has expired, and you try to touch the old channel object, you'll get an error from the server (because the server doesn't know what object you mean anymore). In that case, yes, all the channel state is gone and you need to take extra steps like creating a fresh channel to work with.<br>
<br>I'm not certain, but it might be the case that a few small (but carefully-thought-out) changes to rabbitmq.js could make it sanely and transparently attempt reconnection.<br><br>Tony<br></div></div>-- <br>Tony Garnock-Jones<br>
<a href="mailto:tonygarnockjones@gmail.com" target="_blank">tonygarnockjones@gmail.com</a><br><a href="http://homepages.kcbbs.gen.nz/tonyg/" target="_blank">http://homepages.kcbbs.gen.nz/tonyg/</a><br>