Expose client socket to handle errors
Hi,
Is it possible to expose the socket in ClientImpl to handle errors? At present, if the client disconnects after establishing a connection, there is no way of knowing. If the socket could be exposed, we could add on socket events to handle such events and re-establish the connection.
Is this possible? If not, are there better ways of doing this? Thanks!
When the client loses connection to the server, any write attempt should fail with a socket error. I am not sure how the onDone callback for sockets is implemented internally but given that the connection is bi-directional if your client blocks until you receive a message from rabbit, you might not be able to detect that the socket has been disconnected.
In my view, the best way to detect and surface disconnects is by implementing heartbeats as specified by the amqp spec.
On a side-note, even if the client exposed the socket, simply reconnecting would not be sufficient to resume operation; you would still need to re-define any channels and subscribers. This is the primary reason why it wasn't implemented in the client from the start.
Hi thanks for the response. Yeah in other languages we use amqp for we re-define the network topology manually, so that isn't too much of an issue. We use a TCP keep-alive spec rather than heartbeats, which should throw some sort of socket error nearly immediately open loss of connection, but for some reason I only get an internal 60 second timeout that is uncatchable. Would need to do some more digging if Dart has socket event listeners to then project those out of your library