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

Websocket 1.1.0 proposal #19

Open
wants to merge 9 commits into
base: master
from

Conversation

Projects
None yet
8 participants
@bgourlie

bgourlie commented Feb 13, 2017

Proposed changes

Add onOpen and onClose subscriptions

This would fix #14 and #10 and was my primary motivation for proposing these changes. These subscriptions are important for pretty much any non-trivial scenario, and appears to be the most requested feature for the websocket package.

Reset backoff when page becomes visible

With exponential backoff fixed, reconnect attempts occur far less frequently than when it was broken. It makes sense to reset the backoff when the page becomes visible, otherwise, the user would have to refresh the page if they want the application to reconnect immediately.

Feedback

This pull request is the result of my hacking over the weekend and there are probably issues or things that need to be cleaned up. I also removed keepAlive temporarily just to make it easier to hack in the proposed changes. I'm interested in hearing feedback for the proposed changes, and if/when something concrete is decided, I will clean up this PR.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Feb 13, 2017

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Feb 13, 2017

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@edevil

This comment has been minimized.

Show comment
Hide comment
@edevil

edevil Feb 13, 2017

The hero we needed. I very much approve these changes and I hope you get more feedback.

edevil commented Feb 13, 2017

The hero we needed. I very much approve these changes and I hope you get more feedback.

@bmurphy1976

This comment has been minimized.

Show comment
Hide comment
@bmurphy1976

bmurphy1976 Feb 14, 2017

Good stuff. We have a dashboard that traces logs in real-time and can connect to individual servers to trace running processes using websockets. You have to be on the VPN in order for this functionality to work. Having these additions would allow us to make the user experience much better when the user is not connected to the VPN (i.e. actually tell them they might need to connect). This is long overdue! :)

bmurphy1976 commented Feb 14, 2017

Good stuff. We have a dashboard that traces logs in real-time and can connect to individual servers to trace running processes using websockets. You have to be on the VPN in order for this functionality to work. Having these additions would allow us to make the user experience much better when the user is not connected to the VPN (i.e. actually tell them they might need to connect). This is long overdue! :)

@bgourlie

This comment has been minimized.

Show comment
Hide comment
@bgourlie

bgourlie Feb 18, 2017

Quick update:

I've updated the proposal (not the pull request) to not change message queuing/save behavior. I did this for a couple reasons:

  • After discussing with people on slack and elsewhere, it seems quite a few people rely on this behavior
  • Making it optional will add complexity to the implementation
  • With onOpen and onClose subscriptions, it's possible to track the connection state and prevent messages from being sent at the application level
  • This would no longer require a major version bump as all changes would be backwards compatible.

I did add another item to the proposal, and that is resetting the reconnect backoff when the page becomes visible. This would make reconnects immediate when the user opens the tab, instead of having to potentially wait minutes for the reconnect to happen.

bgourlie commented Feb 18, 2017

Quick update:

I've updated the proposal (not the pull request) to not change message queuing/save behavior. I did this for a couple reasons:

  • After discussing with people on slack and elsewhere, it seems quite a few people rely on this behavior
  • Making it optional will add complexity to the implementation
  • With onOpen and onClose subscriptions, it's possible to track the connection state and prevent messages from being sent at the application level
  • This would no longer require a major version bump as all changes would be backwards compatible.

I did add another item to the proposal, and that is resetting the reconnect backoff when the page becomes visible. This would make reconnects immediate when the user opens the tab, instead of having to potentially wait minutes for the reconnect to happen.

@bgourlie bgourlie changed the title from Websocket 2.0.0 proposal to Websocket 1.1.0 proposal Feb 18, 2017

@cdevienne

This comment has been minimized.

Show comment
Hide comment
@cdevienne

cdevienne May 21, 2017

I think disabling queuing can be done without a major version bump, by adding additional constructor. We would have :

type MySub msg
  = Listen String Bool (String -> msg)
  | KeepAlive String

listen : String -> (String -> msg) -> Sub msg
listen url tagger =
    subscription True (Listen url tagger)

listenNoQueuing : String -> (String -> msg) -> Sub msg
listenNoQueuing url tagger =
    subscription False (Listen url tagger)

cdevienne commented May 21, 2017

I think disabling queuing can be done without a major version bump, by adding additional constructor. We would have :

type MySub msg
  = Listen String Bool (String -> msg)
  | KeepAlive String

listen : String -> (String -> msg) -> Sub msg
listen url tagger =
    subscription True (Listen url tagger)

listenNoQueuing : String -> (String -> msg) -> Sub msg
listenNoQueuing url tagger =
    subscription False (Listen url tagger)

Namek added a commit to Namek/artemis-odb-entity-tracker that referenced this pull request Jul 14, 2017

dev(WebSocket): support onOpen, onClose
based on elm-lang/websocket#19 - merged with binary data support
@ibizaman

If that can be of any help, I just have one comment about this PR. It LGTM although I don't have enough experience for that to be worth something.

What's the next step for this, can I help in some way? Maybe by doing some tests on my side?

@@ -1,5 +1,5 @@
{
"version": "1.0.2",
"version": "2.0.0",

This comment has been minimized.

@ibizaman

ibizaman Aug 15, 2017

Should become 1.1.0 I suppose

@ibizaman

ibizaman Aug 15, 2017

Should become 1.1.0 I suppose

This comment has been minimized.

@fdbeirao

fdbeirao Mar 9, 2018

@ibizaman the public function keepAlive no longer exists, making this a breaking change for consumers. Hence a major version bump is mandatory.

@fdbeirao

fdbeirao Mar 9, 2018

@ibizaman the public function keepAlive no longer exists, making this a breaking change for consumers. Hence a major version bump is mandatory.

This comment has been minimized.

@ibizaman

ibizaman Mar 9, 2018

Good point!

@ibizaman

This comment has been minimized.

@bgourlie

bgourlie Mar 9, 2018

This PR is a proposal, and while it's a breaking change as-is, if something were to be decided on where this PR could be cleaned up for actual merging, the intent would be to make it non-breaking.

@bgourlie

bgourlie Mar 9, 2018

This PR is a proposal, and while it's a breaking change as-is, if something were to be decided on where this PR could be cleaned up for actual merging, the intent would be to make it non-breaking.

@antarestrader

This comment has been minimized.

Show comment
Hide comment
@antarestrader

antarestrader Sep 28, 2017

First, I would like to express my support for this patch.

I would then like to request an additional feature. I would like the details from the onClose method in line 346 of the proposed patch to be sent with Die and be added to the onClose subscription.

antarestrader commented Sep 28, 2017

First, I would like to express my support for this patch.

I would then like to request an additional feature. I would like the details from the onClose method in line 346 of the proposed patch to be sent with Die and be added to the onClose subscription.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment