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

Fix/client server reconnection and timeout #175

Merged

Conversation

ersonp
Copy link
Contributor

@ersonp ersonp commented Jun 2, 2022

Fixes #skywire-1233

Changes:

  • Fixed reconnection edgecase
  • Fixed datarace
  • Added exponential backoff
  • Added .vscode to gitignore
  • Fixed noise read block

How to test this PR:
Given here

ersonp added 3 commits June 2, 2022 10:10
This commit fixes the reconnection edgecase where if the dmsg-server that we are trying to connect to is the last one and the method ce.EnsureSession returns an error then the reconnect  gets stuck on the select statement waiting for either <-ce.done or <-ce.errCh and only moves when the done chan is closed.

In order to fix that we send the error of the method ce.EnsureSession if the dmsg-server that we are trying to connect to is the last one.
pkg/dmsg/client.go Outdated Show resolved Hide resolved
@@ -74,6 +74,10 @@ type Client struct {
conf *Config
porter *netutil.Porter

bo time.Duration // initial backoff duration
Copy link
Member

Choose a reason for hiding this comment

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

Can we use the netutil.Retrier here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

netutil.Retrier doesn't work in this case as we need to wait with exponential backoff in multiple places. And to do that in the retrier we have to return an error but by doing that we have to restart the main loop all over again instead of the current version where we wait between each entry here.

ersonp added 3 commits June 6, 2022 11:00
This commit fixes the read block caused in noise InitiatorHandshake when a dmsg server is closed improperly.

Instead of using the func InitiatorHandshake we use the the method Handshake of ReadWriter which already has a timeout logic.

The method Buffered is added to ReadWriter as it was needed in initClient and server to check the number of bytes that can be read from the buffer rawInput.
@ersonp ersonp marked this pull request as ready for review June 6, 2022 07:41
@mrpalide mrpalide merged commit d4a85dc into skycoin:develop Jun 7, 2022
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

Successfully merging this pull request may close these issues.

3 participants