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

Session not open error on re connection #46

Open
DanPurdy opened this issue Feb 18, 2016 · 0 comments
Open

Session not open error on re connection #46

DanPurdy opened this issue Feb 18, 2016 · 0 comments

Comments

@DanPurdy
Copy link

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!

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

No branches or pull requests

1 participant