Skip to content

authentication error in /meta/handshake sends the client into a 0 interval retry loop #542

@bughit

Description

@bughit

/meta/handshake is the appropriate time to do authentication (as opposed authorization) as that's the first request the client makes and if it can't authenticate it should not be allowed to remain connected.

The following server and client code is responsible:

server

faye/src/protocol/server.js

Lines 150 to 173 in 60141e8

_advize: function(response, connectionType) {
if (array.indexOf([Channel.HANDSHAKE, Channel.CONNECT], response.channel) < 0)
return;
var interval, timeout;
if (connectionType === 'eventsource') {
interval = Math.floor(this._engine.timeout * 1000);
timeout = 0;
} else {
interval = Math.floor(this._engine.interval * 1000);
timeout = Math.floor(this._engine.timeout * 1000);
}
response.advice = response.advice || {};
if (response.error) {
assign(response.advice, { reconnect: 'handshake' }, false);
} else {
assign(response.advice, {
reconnect: 'retry',
interval: interval,
timeout: timeout
}, false);
}
},

client

faye/src/protocol/client.js

Lines 353 to 362 in 60141e8

_handleAdvice: function(advice) {
assign(this._advice, advice);
this._dispatcher.timeout = this._advice.timeout / 1000;
if (this._advice.reconnect === this.HANDSHAKE && this._state !== this.DISCONNECTED) {
this._state = this.UNCONNECTED;
this._dispatcher.clientId = null;
this._cycleConnection();
}
},

If there's an error in /meta/handshake the server sends:
assign(response.advice, { reconnect: 'handshake' }, false);
note that it doesn't even pass the interval to the client causing 0 interval retries

And the client does this._cycleConnection(); on response.

This doesn't seem like good default behavior. At least optionally, an explicit /meta/handshake error should bubble up, ending retries and letting the user of the client decide what to do about it.

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