AstarNetwork/Astar

[rpc server]: astar RPC server doesn't support port in host header

niklasad1 opened this issue · 3 comments

Description

Hey, I got a bug report in jsonrpsee that the client doesn't work and it seems like your RPC node doesn't support specifying
port number in the host header.

Steps to Reproduce

Replace the example steps below with actual steps to reproduce the bug you're reporting.

  1. Use the jsonrpsee ws client and the connection can't be established.

Expected vs. Actual Behavior

2023-08-05T08:41:02.719048Z DEBUG jsonrpsee_client_transport::ws: Connecting to target: Target { sockaddrs: [13.113.163.43:443, 34.67.136.159:443, 20.79.239.175:443], host: "rpc.astar.network", host_header: "rpc.astar.network:443", _mode: Tls, path_and_query: "/" }
2023-08-05T08:41:03.197600Z  INFO soketto::handshake::client: b"GET / HTTP/1.1\r\nHost: rpc.astar.network:443\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: /Up/KapS7wgucrj0hgQ8lw==\r\nSec-WebSocket-Version: 13\r\n\r\n"
2023-08-05T08:41:03.435624Z  INFO soketto::handshake::client: Response { version: Some(0), code: Some(503), reason: Some("Service Unavailable"), headers: [Header { name: "cache-control", value: "no-cache" }, Header { name: "content-type", value: "text/html" }] }

If I remove the port number everything works:

2023-08-07T12:02:41.860366Z DEBUG jsonrpsee_client_transport::ws: Connecting to target: Target { sockaddrs: [13.113.163.43:443, 34.67.136.159:443, 20.79.239.175:443], host: "rpc.astar.network", _mode: Tls, path_and_query: "/" }
2023-08-07T12:02:42.337787Z  INFO soketto::handshake::client: b"GET / HTTP/1.1\r\nHost: rpc.astar.network\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: lvV76PIS+G4o9by4pOvvoA==\r\nSec-WebSocket-Version: 13\r\n\r\n"
2023-08-07T12:02:42.711124Z  INFO soketto::handshake::client: Response { version: Some(1), code: Some(101), reason: Some("Switching Protocols"), headers: [Header { name: "connection", value: "upgrade" }, Header { name: "upgrade", value: "websocket" }, Header { name: "sec-websocket-accept", value: "ekrP7dfZEju64T1DR8iqUqTKy/Y=" }, Header { name: "access-control-allow-origin", value: "*" }, Header { name: "vary", value: "origin" }, Header { name: "vary", value: "access-control-request-method" }, Header { name: "vary", value: "access-control-request-headers" }, Header { name: "access-control-expose-headers", value: "*" }, Header { name: "date", value: "Mon, 07 Aug 2023 12:02:42 GMT" }, Header { name: "set-cookie", value: "astrevm=astar-public-03-pnap; path=/" }] }

Note, it's probably related to your load balancer and the astar node itself as it's using the substrate rpc server AFAIU.

Thank you for the information provided in your report. The issue appears to be related to an SSL handshake failure, which could be occurring on both the client and server sides. For example, when you explicitly specify port 443 in your request on a web browser, the browser interprets it as an SSL request and the server responds accordingly. However, it seems that in the context of jsonrpsee, port 443 is not being interpreted as a https or wss request, resulting in the error you encountered.

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

This issue was closed because it has been stalled for 7 days with no activity.