pika/pika — pull request #516 by jimhorng (2014-11-21 11:34:04+00:00)
Title: make skip IncompatibleProtocolError as optional for client to adapt scenarios like ELB connection

In my scenario with configurations
* tornado server publishes message to MQ through ELB
* ELB in front of rabbitMQ(s)
* rabbitMQ setup as a cluster

when some of rabbitMQ is down and the cluster is not in function, tornado's pika connection with receive error like

"""
[2014-11-19 01:04:30,841][ERROR ][tornado.application:681] : Exception in I/O handler for fd 21#012Traceback (most recent call last):#01
2 File "/tornado/ioloop.py", line 671, in start#012 self._handlers[fd](fd,
events)#012 File "/tornado/stack_context.py", line 331, in wrapped#012 raise_exc_info(exc)#012 File "/tornado/stack_context.py", line 302, in wrapped#012
ret = fn(*args, **kwargs)#012 File "/pika/adapters/base_connection.py”, line 322, in _handle_events#012 self._handle_read()#012
File "/pika/adapters/base_connection.py", line 348, in _handle_read#012
return self._handle_disconnect()#012 File "/pika/adapters/base_connection.py", line 248, in _handle_disconnect#012 self._adapter_disconnect()#012 File "/pika/adapters/tornado_connection.py", line 75, in _adapter_disconnect#012
super(TornadoConnection, self)._adapter_disconnect()#012 File "/pika/adapters/base_connection.py", line 137, in _adapter_disconnect#012
self._check_state_on_disconnect()#012 File "/pika/adapters/base_connection.py", line 149, in _check_state_on_disconnect#012
raise exceptions.IncompatibleProtocolError#012IncompatibleProtocolError
"""

And all the error handling and re-connection mechanism will NOT be invoked since the exception breaks the calls to _on_connection_closed which registered error handling callbacks.
```
def _handle_disconnect(self):
"""Called internally when the socket is disconnected already
"""
self._adapter_disconnect() # BREAKS HERE !
self._on_connection_closed(None, True)
```

In this scenario "IncompatibleProtocolError" is not treated as severe error and the connection can be recovered by re-connecting. Therefore I proposed that client can have option to skip this error for the appropriate scenario.

Thanks.