On 11 June 2012 09:55, Marek Majkowski <span dir="ltr">&lt;<a href="mailto:majek04@gmail.com" target="_blank">majek04@gmail.com</a>&gt;</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&#39;m afraid there is no &quot;proper&quot; way. When it works - great. But on<br>
network errors, I&#39;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&#39;t think it&#39;s actually so bad in principle, though the implementation isn&#39;t there yet.<br><br>The channel object on the server side has a timeout - if there&#39;s a waiting longpoll, the timer isn&#39;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&#39;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 &quot;connections&quot; 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&#39;ll get an error from the server (because the server doesn&#39;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&#39;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>