Skip to content
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

Events of attempts to reconnect #101

Open
GolDiV opened this issue Oct 30, 2018 · 5 comments
Open

Events of attempts to reconnect #101

GolDiV opened this issue Oct 30, 2018 · 5 comments
Labels
enhancement help wanted semver-minor Contains backward-compatible features

Comments

@GolDiV
Copy link

GolDiV commented Oct 30, 2018

Is it possible to somehow get the events of attempts to reconnect to the asterisk websocket? Now it can be seen only through debug, but I want to process them on the client in production

@chadxz
Copy link
Owner

chadxz commented Oct 30, 2018

Hey Dmitriy! Thanks for the feedback. That isn't currently possible, but it wouldn't be a large code change. I can try to do that soon, or I would accept a PR for that functionality.

@chadxz
Copy link
Owner

chadxz commented Oct 30, 2018

retry.timeouts(opts) can be used to get the list of timeout values to be able to report how long until the next retry. In ReconnectingWebsocket.js we can alter both handleError and handleClose to set a private member variable to indicate we are reconnecting. Then in the connect method, check for that and emit an event on each connection attempt, along with some metadata about what attempt number it is, how many total attempts there will be, and the time until the next attempt. Lastly, we'd need to reset the reconnecting instance var once we exhaust our attempts or are successful.

And of course write tests 😊 (the hard part)

@GolDiV
Copy link
Author

GolDiV commented Oct 30, 2018

Hi Chad! I'm not a good programmer yet, so I can't do PR. However, I got your idea. I reasoned about the same.
Your project in my opinion is very interesting. I tried 'ari-client', but I liked 'awry' more.

@GolDiV
Copy link
Author

GolDiV commented Oct 30, 2018

And a few more points. If you start to connect to a remote server in the absence of a network, errors can also not be caught without debug. They simply have nowhere to catch as there is no websocket object. This object appears only when there is a connection, if I understand correctly.
The second point is related to ping. You have this undocumented, but it is done simply with events._ws.ping(). This makes it easy to detect a broken connection. I have not found another way to detect broken connections. However, maybe there is a better way?

@chadxz
Copy link
Owner

chadxz commented Oct 30, 2018

Thanks for the additional feedback Dmitriy 😊 I created #102 and #103 to track those and allow us to continue that discussion in a dedicated place.

Don't worry about the PR if you feel uncomfortable doing that. I think this feedback is great and would like to investigate these things and see if we can address them. My time is limited though so it may take a while 😅 I'm sure you understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted semver-minor Contains backward-compatible features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants