Closed nodebreaker0-0 closed 1 year ago
I'm experiencing something similar, with the same error
i’m working on connecting a gm rollup to a frontend, but running into an error with cors permissions on websockets for the RPC (26657). i did some research on what is required to enable wss connections from anywhere, and before starting the chain, i now am modifying cors_allowed_origins = []
to cors_allowed_origins = ["*"]
in .gm/config/config.toml
Here are the steps to reproduce:
bash init-local.sh
in the root of the gm
directory
~/.gm/config/config.toml
and verify that the [rpc]
section has changed cors_allowed_origins = []
to cors_allowed_origins = ["*"]
# example of connection data in keplr
{
"rpc": "https://rpc.cosmos.directory/gmrollup",
"rest": "https://rest.cosmos.directory/gmrollup",
"chainId": "gm",
"chainName": "my gm rollup",
...
http://127.0.0.1:26657/
as RPC and http://127.0.0.1:1317/ for LCD
5:12PM ERR failed to update to WebSocket connection error="websocket: request origin not allowed by Upgrader.CheckOrigin"
I worked with @tuxcanfly on this testing out a few things to isolate the issue:
cors_allowed_origins = []
to cors_allowed_origins = ["*"]
, and saw the same behavior--rpc.cors_allowed_origins
, this is not in the Rollkit node's CLI menu, so it failed to start chain, which is expectedcors_allowed_origins = ["localhost"]
and saw the same errorcors_allowed_origins = ["0.0.0.0"]
and saw the same errorwebsocat
(brew install websocat
) and running websocat ws://127.0.0.1:26657/websocket
, the connection opened. then, sending { "jsonrpc": "2.0", "method": "subscribe", "params": ["tm.event='NewBlock'"], "id": 1 }
resulted in {"jsonrpc":"2.0","error":{"code":-32600,"message":"json: cannot unmarshal string into Go value of type json.subscribeArgs","data":["tm.event='NewBlock'"]},"id":1}
http://127.0.0.1:26657
, http://localhost:26657
, and http://0.0.0.0:26657
--rpc.unsafe
flag in the init-local.sh
script on the rollkit start command, same resulti’m not getting an error for the API endpoint (port 1317). i enabled it using --api.enable --api.enabled-unsafe-cors
, so I think that this is working properly
Keplr issue & why we need websockets:
3 WS related issues here: https://github.com/rollkit/rollkit/issues/448
Tendermint issue: https://github.com/tendermint/tendermint/issues/9316
It looks like the following may be related to fixes for the REST API (but not for the RPC, which is the issue we are facing now)
Video: https://www.loom.com/share/ab6e87f5ef224c74a864881dbed37b01
good news, i don't get the same error
not so great news, we have a new one 😈
3:41PM ERR failed to read next WebSocket message error="websocket: close 1005 (no status)"
and on keplr it says: Failed to get response /cosmos/base/tendermint/v1beta1/node_info from lcd endpoint
If i curl the endpoint:
curl -X GET "http://localhost:1317/cosmos/base/tendermint/v1beta1/node_info" -H "accept: application/json"
{
"code": 12,
"message": "unknown service cosmos.base.tendermint.v1beta1.Service",
"details": [
]
}
I see the following on my logs on rollkit node:
4:04PM DBG served RPC HTTP response duration=0 method=GET module=api-server remoteAddr=127.0.0.1:56878 status=501 url={"ForceQuery":false,"Fragment":"","Host":"","OmitHost":false,"Opaque":"","Path":"/cosmos/base/tendermint/v1beta1/node_info","RawFragment":"","RawPath":"","RawQuery":"","Scheme":"","User":null}
4:05PM DBG served RPC HTTP response duration=0 method=GET module=api-server remoteAddr=[::1]:56914 status=501 url={"ForceQuery":false,"Fragment":"","Host":"","OmitHost":false,"Opaque":"","Path":"/[object Module]","RawFragment":"","RawPath":"/[object%20Module]","RawQuery":"","Scheme":"","User":null}
When I try to use the frontend at http://localhost:1317 to test the endpoint, i see the same details/errors:
@jcstein @tuxcanfly Thanks guys, We've already seen the just pre-forking that part for quick app adoption! https://github.com/nodebreaker0-0/rollkit/tree/v0.7.3-wsorg
gm @nodebreaker0-0 - were you able to bypass the Failed to get response /cosmos/base/tendermint/v1beta1/node_info from lcd endpoint
or 3:41PM ERR failed to read next WebSocket message error="websocket: close 1005 (no status)"
errors?
@jcstein gm bro, hmm... It all is well,
this is the SovereignChain product endpoint using the rollkit below. Try what you're trying to do!
wss://cel-cre.crescent.network:26657/websocket
https://cel-cre.crescent.network:1317/cosmos/base/tendermint/v1beta1/node_info
If this succeeds, see the code below, please note that if the code deviates much from the SDK standards, the probability of errors will increase.
https://github.com/nodebreaker0-0/rollkit/tree/v0.7.4-ws-main
Your configuration may be incorrect,
config.toml cors_allowed_origins = ["*", ] experimental_close_on_slow_client = false
thanks @nodebreaker0-0!
i do have in my config.toml
:
cors_allowed_origins = ["*"]
and experimental_close_on_slow_client = false
cc @nashqueue
Tested and was be fixed by #864 @nodebreaker0-0
websocat ws://127.0.0.1:26657/websocket
{ "jsonrpc": "2.0", "method": "subscribe", "id": 7, "params": { "query": "tm.event='NewBlock'" } } {"jsonrpc":"2.0","result":{},"id":7}
There is still unknown service cosmos.base.tendermint.v1beta1.Service
which is the same as #944 so let's follow up there.
version: https://github.com/nodebreaker0-0/crescent/blob/crescent-sdk-rollmint-v0.0.0/go.mod#L348
A bug was detected while trying to send a transaction through a web socket.
web-log : WebSocket connection to 'wss://cel-cre.crescent.network:26657/websocket' failed: Error sign TX Error: hex string contains invalid characters
node-log : 12:10PM ERR failed to update to WebSocket connection error="websocket: request origin not allowed by Upgrader.CheckOrigin"
It's not happening in the standard tender mint, is there a solution?