Skip to content

Cannot reopen websocket after calling $close() #8

Open
@gtarcea

Description

@gtarcea

ng-websocket will not allow you to re-open a websocket if you have called $close() on it. After working through the code I've found the problem is in the function $websocketService line 68:
if (typeof ws === 'undefined') {

If the socket was previously opened and then closed, then wss.$get() will return the ws that was closed, so ws is not equal to 'undefined' and it never actually trys to create a new WebSocket. I changed line 68 to:
if (typeof ws === 'undefined' || ws.$status() === ws.$CLOSING || ws.$status() === ws.$CLOSED) {

I can send a pull request if required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions