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

Detailed port-in-use error #7316

Merged
merged 9 commits into from
Aug 24, 2024
Merged

Detailed port-in-use error #7316

merged 9 commits into from
Aug 24, 2024

Conversation

alexb5dh
Copy link
Contributor

@alexb5dh alexb5dh commented Aug 8, 2024

Changes

Provide details regarding port configuration when binding fails due to port being in use. Example:

08 Aug 09:07:24 | Init failed Nethermind.Network.PortInUseException: Port 5432 is in use. If you intend to run 2 or more nodes on one machine, ensure you have changed all configured ports under: 
        Network.P2PPort
        Network.DiscoveryPort
        JsonRpc.WebSocketsPort
        JsonRpc.Port
        JsonRpc.EnginePort
 ---> System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted.
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at DotNetty.Transport.Channels.Sockets.TcpServerSocketChannel.DoBind(EndPoint localAddress)
   at DotNetty.Transport.Channels.AbstractChannel.AbstractUnsafe.BindAsync(EndPoint localAddress)
--- End of stack trace from previous location ---
   at DotNetty.Transport.Bootstrapping.AbstractBootstrap`2.DoBindAsync(EndPoint localAddress)
   at Nethermind.Network.NetworkHelper.HandlePortTakenError[T](Func`1 action, Int32[] ports)
   --- End of inner exception stack trace ---
   at Nethermind.Network.NetworkHelper.HandlePortTakenError[T](Func`1 action, Int32[] ports)

Testing

Requires testing

  • No

If yes, did you write tests?

  • No

Requires explanation in Release Notes

  • No

@alexb5dh alexb5dh self-assigned this Aug 8, 2024
@alexb5dh alexb5dh requested a review from rubo as a code owner August 8, 2024 06:13
@LukaszRozmej
Copy link
Member

OpenEthereum had a good config value for this:

    --ports-shift=[SHIFT]
        Add SHIFT to all port numbers OpenEthereum is listening on. Includes network port and all servers (HTTP JSON
        -RPC, WebSockets JSON-RPC, SecretStore). (default: 0)

Maybe we should add something similar?

Copy link
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

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

Would be good to indicate which port conflict resulted in this error.

@alexb5dh
Copy link
Contributor Author

alexb5dh commented Aug 8, 2024

Would be good to indicate which port conflict resulted in this error.

@LukaszRozmej, it already does, but by port number as you can see in the PR description.

I decided to not include specific option name due to some of the calls not having a single port to blame. For example, WebHost.Start in JsonRpcRunner can involve 2 or 3 ports depending on the configuration and there's no way to extract exact conflicting one.

Regarding showing all port options in the error. Idea was that since the issue is likely to happen due to an attempt to run another instance on the same machine, it would be better to show all the configurable ports, instead of showing a new (failed one) each run.

@LukaszRozmej
Copy link
Member

@alexb5dh can you resolve conflicts?

…rt-error

# Conflicts:
#	src/Nethermind/Nethermind.Network.Discovery/DiscoveryApp.cs
#	src/Nethermind/Nethermind.Network.Discovery/Discv5/DiscoveryV5App.cs
@alexb5dh
Copy link
Contributor Author

@LukaszRozmej, done

@LukaszRozmej LukaszRozmej merged commit ad86f41 into master Aug 24, 2024
66 checks passed
@LukaszRozmej LukaszRozmej deleted the feature/detailed-port-error branch August 24, 2024 16:59
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.

2 participants