-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
node: show websocket url in logs #22307
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it out and it LGTM, thanks for the fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestNodeRPCPrefix
looks broken, will take a look
This diff will fix the failing test, ws endpoint was taking the endpoint of the http server instead of ws --- a/node/node_test.go
+++ b/node/node_test.go
@@ -558,7 +558,7 @@ func TestNodeRPCPrefix(t *testing.T) {
func (test rpcPrefixTest) check(t *testing.T, node *Node) {
t.Helper()
httpBase := "http://" + node.http.listenAddr()
- wsBase := "ws://" + node.http.listenAddr()
+ wsBase := "ws://" + node.ws.listenAddr()
if node.WSEndpoint() != wsBase+test.wsPrefix {
t.Errorf("Error: node has wrong WSEndpoint %q", node.WSEndpoint()) |
I think we put them on the same port on purpose when the port is zero. Is it a problem to have them on the same port in this case? |
No, I thought it was more UX-friendly this way, but it's really just a "pick either option" kind of thing. Should I revert that? |
I would prefer to keep them on the same port in this case. |
Fixed |
url := fmt.Sprintf("ws://%v", listener.Addr()) | ||
if h.wsConfig.prefix != "" { | ||
url += h.wsConfig.prefix | ||
} | ||
h.log.Info("WebSocket enabled", "url", url) | ||
} | ||
// if server is websocket only, return after logging | ||
if !h.rpcAllowed() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Is there ever a case where neither ws
nor rpc
is allowed, but we still want to not exit here? I think the answer is no, but .... graphql..? cc @renaynay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graphql cannot be allowed if rpc is disabled
This PR does two things:
Ifgeth --dev --ws --ws.port 0 --http --http.port 0
is used, then ws and http are both randomized, to different ports.geth --dev --ws --ws.port 9999 --http --http.port 9999
, then it shows in the logs that, yes, websocket is up, even if it's on the same port.