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

feat: make protocols updatable #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

XadillaX
Copy link

@XadillaX XadillaX commented May 19, 2020

In my scene, protocol should be updatable too. So this feature is inspired from UrlProvider.

@XadillaX XadillaX force-pushed the protocols-provider branch from 52e26d5 to 6357e53 Compare May 19, 2020 07:13
@coveralls
Copy link

coveralls commented May 19, 2020

Coverage Status

Coverage decreased (-0.3%) to 94.581% when pulling d00224c on XadillaX:protocols-provider into 05a2f7c on pladaria:master.

@XadillaX XadillaX force-pushed the protocols-provider branch from 6357e53 to 75c3473 Compare May 19, 2020 07:30
@XadillaX
Copy link
Author

/ping @pladaria

1 similar comment
@XadillaX
Copy link
Author

/ping @pladaria

@XadillaX XadillaX force-pushed the protocols-provider branch from 75c3473 to d00224c Compare May 25, 2020 08:28
@bj00rn
Copy link

bj00rn commented Apr 16, 2021

@pladaria @XadillaX can we get this merged?

Having Protocols updatable would be awesome. A strong (but hackish) use case for this is sending JWT token securely when establishing connection, since the this is the only header available in the websocket browder implementation

threepointone added a commit to partykit/partykit that referenced this pull request Jan 8, 2023
This forks `reconnecting-websocket` into our own package, and adds some functionality from abandoned PRs on the source repo. Of note:
- pladaria/reconnecting-websocket#166 Fix: handle error if getNextUrl throws
- pladaria/reconnecting-websocket#132 feat: make protocols updatable
- pladaria/reconnecting-websocket#141 [Fix] Socket doesn't connect again after closing while connecting

(TODO: more)
- pladaria/reconnecting-websocket#163 Support for Dynamic Protocols
- pladaria/reconnecting-websocket#47 reconnecting and reconnectscheduled custom events
threepointone added a commit to partykit/partykit that referenced this pull request Jan 8, 2023
This forks `reconnecting-websocket` into our own package, and adds some functionality from abandoned PRs on the source repo. Of note:
- pladaria/reconnecting-websocket#166 Fix: handle error if getNextUrl throws
- pladaria/reconnecting-websocket#132 feat: make protocols updatable
- pladaria/reconnecting-websocket#141 [Fix] Socket doesn't connect again after closing while connecting

(TODO: more)
- pladaria/reconnecting-websocket#163 Support for Dynamic Protocols
- pladaria/reconnecting-websocket#47 reconnecting and reconnectscheduled custom events
@Phil1216
Copy link

I was this close to coding up this feature myself. I too am using protocols for sending tokens.

@bj00rn
Copy link

bj00rn commented Aug 28, 2023

Sad to see this library abandoned..

Partykit looks promising!

Here is a naive workaround i was using..

export default class Socket extends ReconnectingWebSocket {
    constructor(urlProvider, protocolsProvider) {
        /**
         * Workaround to authenticate websocket over Sec-Websocket-Protocol header
         * see issue at (https://github.com/whatwg/websockets/issues/16)
         * @class _WebSocket
         * @extends {WebSocket}
         */
        class _WebSocket extends WebSocket {
            constructor(url) {
                super(url, protocolsProvider())
            }
        }

        super(urlProvider, undefined, {
            WebSocket: _WebSocket,
        })
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants