SimplyStaking / panic_polkadot

🚨 PANIC for Polkadot
Apache License 2.0
36 stars 8 forks source link

TypeError: Cannot read property 'api' of undefined #15

Closed jeroenroodnat closed 4 years ago

jeroenroodnat commented 4 years ago

I upgraded from 2.0.1 to 2.1.2 docker image. Alerter is not connecting anymore. Found below in the general log file. My API server is running. The "TypeError: Cannot read property 'api' of undefined" concerns me. I am running container in k8s.

11/09/2020 01:00:42 PM - general - INFO - Trying to retrieve data from the API of polkadot-private-node 11/09/2020 01:00:42 PM - general - ERROR - TypeError: Cannot read property 'api' of undefined 11/09/2020 01:00:42 PM - general - INFO - Failed to retrieve data from the API of polkadot-private-node

jeroenroodnat commented 4 years ago

using shell into container I check connectivity to the Node as well as API server and that is all working as expected.

dillu24 commented 4 years ago

Can you confirm whether the api/rpc/sytem/chain endpoint works from the API server using postman or curl?

This issue is occurring when the alerter starts, and the endpoint above is the only API call that is called on startup. Can you also answer the following questions?:

jeroenroodnat commented 4 years ago

It looks like it is an issue with the API-server.

curl -X GET http://localhost:3000/api/pingNode?websocket=ws://polkadot-private-node-0.polkadot-private-node.ksm.svc.cluster.local:9944

{"error":"TypeError: Cannot read property 'api' of undefined"}

Use latest version of API server. Dockerhub image. Polkadot nodes is running 0.8.23.

If I change the websocket url to the IP I get the following error, which makes sense as config is not setup.

{"error":"An API for ws://10.42.2.44:9944 needs to be setup before it can be queried"}

my node config is:

[node_1] node_name = polkadot-private-node ws_url = ws://polkadot-private-node-0.polkadot-private-node.ksm.svc.cluster.local:9944

jeroenroodnat commented 4 years ago

Changed my node config to have an IP in the ws_url and not a hostname. This works. Not sure why yet.

For k8s this is suboptimal as the IP might change so you really want to use hostname

jeroenroodnat commented 4 years ago

I reverted API server back to 1.18.1 and this works with hostname in ws://. So it seems it is a API server issue in 1.23.1

dillu24 commented 4 years ago

Sorry for the delay.

There is no logic in the API server which refuses connections with the host name. In fact whenever I use a public node like wss://kusama-rpc.polkadot.io/ to connect the API server with, it is always successful.

Can you perform the following tests?:

It could also be that there was a change in the underlying polkadot-js/api, which the API server uses.

dillu24 commented 4 years ago

Another important note is that the latest version of PANIC is no longer compatible with version 1.18.1 of the API server.