Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

If an existing peer tries to connect to us, the inbound connection is kept even though they are not added to our peer list - Closes #4170 #4171

Merged
merged 6 commits into from
Aug 30, 2019

Conversation

jondubois
Copy link
Contributor

@jondubois jondubois commented Aug 30, 2019

What was the problem?

In one of the if conditions where we refuse to add the inbound peer, we forget to disconnect their socket.

How did I solve it?

  • Disconnect the inbound socket with a relevant code/message.
  • The test case related to peer discovery had to be adjusted to account for a small change in discovery time.

How to manually test it?

A new integration test case was added.

Run npm test

Review checklist

export const FORBIDDEN_CONNECTION = 4403;
export const FORBIDDEN_CONNECTION_REASON = 'Peer is not allowed to connect';

export const DUPLICATE_CONNECTION = 4404;
Copy link

@diego-G diego-G Aug 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@jondubois jondubois Aug 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first/original connection can be outbound so the suggested name would create confusion because it makes it sound like there are two duplicate inbound connections which is usually not the case.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it wasn't a suggestion. I've just showed a similar variable that we are introducing in another PR #4169. Shall we change this variable's name or the other?

Copy link
Contributor Author

@jondubois jondubois Aug 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think it may be the same error. We should change it in the other PR so that they match because Ishan is working on it in parallel.


public constructor(peerPoolConfig: PeerPoolConfig) {
super();
this._peerMap = new Map();
this._peerPoolConfig = peerPoolConfig;
this._inboundPeerConfig = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does inbound have no config for banTime and wsMaxPayload but outbound does

Copy link
Contributor Author

@jondubois jondubois Aug 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wsMaxPayload is not necessary for inbound because it is set on the SocketCluster server (not on the peer socket). It seems that banTime is not used in any of the peer classes. I guess we can remove it.

@shuse2 shuse2 merged commit e516a71 into hotfix/2.3.2 Aug 30, 2019
@shuse2 shuse2 deleted the 4170-disconnect_duplicate_peer branch August 30, 2019 14:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants