-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit and Publish Peer Connection Errors #312
Conversation
A zetta instance's `pubsub` can be used to react to peer client disconnect events. Currently, the _peer_client_ module will emit a "closed" event for both a socket error *and* socket close event. This means the zetta handle of 'error' events will never be called. This change adds `emit('error', err)` to the _peer_client_ module, and updates _zetta_ to publish the '_peer/disconnect' event with the `error` object as an additional property of the published data. `publish('_peer/disconnect'), {peer:peerClient, error: error});` This allows code that subscribes to the peer disconnect events to react specifically to errors.
Updated _zetta_ module to publish '_peer/error' instead of disconnect on a peer client 'error' event. This should not cause an issues with existing code because the 'error' event was previously never emitted.
Hi @wooliet, To start i'd be interested in why and what information you're currently lacking with zetta? Is it just the I have a concerns about adding another
I would like to propose an alternative approach. Have the peer_client emit only the |
I have a zetta instance "linked" to another. When the main instance restarts and has a new location, I want to be sure and trigger a reconnect process for the original. When the instance tries to connect to a bad location, the ultimate error is "ECONNREFUSED". I wanted to handle that specific issue.
"Alternative Approach": Your suggestion is the same as my first pass at this. But when I realized that the "error" event is never actually emitted by peer_client, it seemed cleaner to me to publish a unique topic as opposed adding additional data to existing topics. |
@AdamMagaluk Yeah, that looks right. I agree it'd be better to not emit both "closed" and "error". I don't know the implications of adding the |
The small update i made in event_socket would allow ws clients subscribed to |
@wooliet Would you want to include that one small change in event_socket then i'd be happy to get this PR merged in. |
I'm sorry @AdamMagaluk , I missed this. What specific changes would you like for me to add? Those you linked to in lib/event_socket.js? |
+1 |
1 similar comment
+1 |
Closing but opened new PR with commits and tests. #317 |
* Emit & Publish Peer Connection Errors A zetta instance's `pubsub` can be used to react to peer client disconnect events. Currently, the _peer_client_ module will emit a "closed" event for both a socket error *and* socket close event. This means the zetta handle of 'error' events will never be called. This change adds `emit('error', err)` to the _peer_client_ module, and updates _zetta_ to publish the '_peer/disconnect' event with the `error` object as an additional property of the published data. `publish('_peer/disconnect'), {peer:peerClient, error: error});` This allows code that subscribes to the peer disconnect events to react specifically to errors. * Publish Error Updated _zetta_ module to publish '_peer/error' instead of disconnect on a peer client 'error' event. This should not cause an issues with existing code because the 'error' event was previously never emitted. * Update _peer_client_ to only emit the "error" event. #312 (comment) * Updated PR per @AdamMagaluk; changes to match _event_socket_ in: 6206dc5 * Added tests to ensure PeerClients emits the proper close event * Remove use of _peer/error and use only _peer/disconnect
A zetta instance's
pubsub
can be used to react to peer client disconnect events. Currently, the peer_client module will emit a "closed" event for both error and close events.peer_client
The following zetta handle of "error" events (and it publish of a "disconnect" topic) will never be called.
This PR adds
emit('error', err)
to the peer_client module, and updates the zetta handler to publish a '_peer/error' topic with theerror
andpeerClient
objects.It is not expected to cause issues with current code because the "error" event handler was previously never called.