Skip to content

Session not open error on re connection #46

@DanPurdy

Description

@DanPurdy

I have an application that opens a connection once a user logs in via our apps initial abstract state resolve which calls the following in my service.

// sockets service
if (!this.$wamp.connection.isConnected) {
    this.$wamp.open();
}

It also fires two remote procedure calls at this point to get a list of events and then subscribes to a related channel for subsequent updates I've included one half of this below.

//initial abstract state
resolve: {
            initConnection: ['SocketService', (SocketService) => {
                return Promise.all(
                    [
                        SocketService.openConnection(),
                        SocketService.getInitialEnquiries()
                    ]
                );
            }]


// Socket service
getInitialEnquiries() {
        return this.$wamp.call('store.enquiry.list', [['new', 'cancelled', 'in-progress']]).then(data => {
            return this.EnquiryModel.setCollection(data.result);
        });
    }

subscribeEnquiryStatus() {
        this.$wamp.subscribe('enquiry.channel', args => {
            args.forEach(item => {
                this.EnquiryModel.updateCollectionItem(item.id, item);
            });
        });
    }
//etc etc

We listen for a logout event which we then use to fire a $wamp.close(). This all seems to work fine, but when we login again our initial abstract state resolve fails with the errors session not open for our calls. Once the message that we are connected again is received we can navigate to that state without issue and the calls work fine.

It seems like I need to somehow reset the connection to it's default state in order for it to queue the calls again but I would of thought the close itself would of handled that. Am i doing something wrong here as it seems related to #31

Also in the event that a network error happens and the connection drops I assume i'd need to fire those calls again to make sure my data is up to date but the subscriptions themselves should be still valid unless the connection completely times out and is closed. This will probably lead to similar problem as above.

Any help would be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions