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

Configurable write timeout for websocket server #1554

Merged
merged 11 commits into from
Jul 15, 2021

Conversation

fedejinich
Copy link
Contributor

Description

Any websocket connection will be closed after a certain write timeout. Currently set to 30 seconds but it can be less (I think it should be less).

This implied

  • in adding a WriteTimeoutHandler to the Web3WebSocketServer
  • And creating an RskWebSocketJsonRpcHandler to close a connection after exceding the timeout.
  • Also renamed RskJsonRpcHandler to RskWebSocketJsonRpcHandler, since it was only used for the websocket server.

Also take account that I had to modify the RskWebSocketJsonRpcHandler, there where two reference counted objects that are producing memory leaks when the connection is closed due to exceding the timeout:

class RskWebSocketJsonRpcHandler {
    protected void channelRead0(ChannelHandlerContext ctx, ByteBufHolder msg) {
      ... 
      RskJsonRpcRequest request = serializer.deserializeRequest(new ByteBufInputStream(msg.copy().content()));
      ...
      ctx.fireChannelRead(msg.retain());
    }
}

This last one is also unnecesary, there's no need to retain a msg that will be passed anyway to the next handler.

Unit Testing

This should be covered by an integration test, I've only added one assertion to make sure that the timeout has properly been set.

Also if you want to verify netty is not producing any other buffer leak, you can activate the leak decector by adding

java -Dio.netty.leakDetection.level=advanced 

Useful links

@lgtm-com
Copy link

lgtm-com bot commented Jun 9, 2021

This pull request introduces 1 alert and fixes 1 when merging 9b11699 into 5f5e610 - view on LGTM.com

new alerts:

  • 1 for Potential input resource leak

fixed alerts:

  • 1 for Potential input resource leak

@lgtm-com
Copy link

lgtm-com bot commented Jun 15, 2021

This pull request fixes 1 alert when merging 38d404b into c94ab4a - view on LGTM.com

fixed alerts:

  • 1 for Potential input resource leak

@lgtm-com
Copy link

lgtm-com bot commented Jul 7, 2021

This pull request fixes 1 alert when merging dff86bf into 31b85cd - view on LGTM.com

fixed alerts:

  • 1 for Potential input resource leak

@lgtm-com
Copy link

lgtm-com bot commented Jul 7, 2021

This pull request fixes 1 alert when merging d733009 into 31b85cd - view on LGTM.com

fixed alerts:

  • 1 for Potential input resource leak

@lgtm-com
Copy link

lgtm-com bot commented Jul 7, 2021

This pull request fixes 1 alert when merging bdc3eb8 into 31b85cd - view on LGTM.com

fixed alerts:

  • 1 for Potential input resource leak

@lgtm-com
Copy link

lgtm-com bot commented Jul 7, 2021

This pull request fixes 1 alert when merging 0b1ee3b into 31b85cd - view on LGTM.com

fixed alerts:

  • 1 for Potential input resource leak

@lgtm-com
Copy link

lgtm-com bot commented Jul 8, 2021

This pull request fixes 1 alert when merging 4683d89 into 31b85cd - view on LGTM.com

fixed alerts:

  • 1 for Potential input resource leak

Copy link
Contributor

@marcciosilva marcciosilva left a comment

Choose a reason for hiding this comment

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

lgtm m8

@lgtm-com
Copy link

lgtm-com bot commented Jul 14, 2021

This pull request fixes 1 alert when merging 61cc3a4 into 10a1941 - view on LGTM.com

fixed alerts:

  • 1 for Potential input resource leak

@aeidelman aeidelman merged commit e0589f3 into rsksmart:master Jul 15, 2021
@aeidelman aeidelman added this to the Iris v3.1.0 milestone Aug 20, 2021
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.

4 participants