Closed KumarUjjwal2022 closed 1 year ago
You don’t appear to be awaiting the call to getAllCurrencies
No @justinr1234 Actually that also i have done. As I have used getAllCurrencies(ac) in other module as it is like helper method. You can see i have use await also.
await Balance.getAllCurrencies(finalVal.response.account);
And also i made client.connect() in getAllCurrencies(ac) and at end client.Disconnect() now i am getting another error i.e. DisconnectedError: WebSocket is not open: readyState 2 (CLOSING)
The updated code of this method getAllCurrencies(ac) is below:-
async function getAllCurrencies(ac) { await client.connect(); const xrpBalance = await getXrpBalance(ac); const tokenBalance = await getIssuedCurrBalance(ac); tokenBalance.unshift(xrpBalance) await client.disconnect(); return tokenBalance; }
So can you guess what actually is issued.?
Are you in a browser environment? If so, I believe we have a fix for this error message that hasn’t been released yet.
Edit: I don’t think there’s fix for it. But this was fixed in 2.7.0 originally for browser environments.
Actually @justinr1234 I have upgraded to XRPL version 2.7.0 at backend i.e. nodejs . I haven't used this NPM in frontend i.e. reactjs.
Earlier i was using XRPL version 2.6.0 to getBalance() of an account but for few account i got INVALID_PARAMS and then as per the suggestion i used this method to get XRPL balance i.e. account_lines and account_info and also updated XRPL to 2.7.0 at backend environment.
@KumarUjjwal2022 would you be able to share your code with me? It would be easier to look at the failing code.
Is also recommend wrapping all your awaits in a try catch block to see if you can figure out other errors happening. Did you verify each step of the way that the functions were completing successfully?
@justinr1234 We already have try catch in method where we are using this helper method i.e. and that catch block gives the above mentioned error , my code is :-
try { const { ac } = req.decoded; let currency = await Balance.getAllCurrencies(ac); console.log("balance" , currency ) } catch (error) { console.log("error get balance=", error) }
This is code where getAllCurrencies(ac) method is used.
Would you be able to invite me to your code so I can take a look?
Okay @justinr1234 Do we need to have a call on zoom or how you want to take a look?
@KumarUjjwal2022 if you can invite me to a GitHub repo with the failing code I can look
@justinr1234 Actually due to rules and regulation we couldn't provide you code as it is confidential So it will be helpful for me if you can meet on zoom or any other means on call.
@justinr1234 how can we resolve it. Now i'm getting this issue frequently. The exact error is :-
XrplError: Websocket connection never cleaned up.
at Connection.
@KumarUjjwal2022 please provide a minimal code example that we can run to reproduce the issue.
@KumarUjjwal2022 Here are some instructions on producing a minimal code example: https://stackoverflow.com/help/minimal-reproducible-example
@justinr1234 @intelliot Actually at first their is sign in process and then i use to connect with ledger and fetch balance , while fetching balance i.e. getting account_info and account_lines . At that time it gives Websocket connection never cleaned. sometimes this error comes frequently and sometimes it takes time.
The code is below:- / Get accounts all XRP / async function getXrpBalance(ac) { await client.connect(); let response = await client.request({ method: "account_info", account: ac, ledger_index: "validated", }); return { currency: "XRP", value: xrpl.dropsToXrp(response.result.account_data.Balance), }; }
/ get accounts all currencies/token / async function getIssuedCurrBalance(ac) { let response = await client.request({ method: "account_lines", account: ac, ledger_index: "validated", }); return response.result.lines.map((val) => ({ value: val.balance, currency: val.currency, issuer: val.account})); }
/ get accounts all balance / async function getAllCurrencies(ac) { const xrpBalance = await getXrpBalance(ac); const tokenBalance = await getIssuedCurrBalance(ac); tokenBalance.unshift(xrpBalance) await client.disconnect(); return tokenBalance; }
and this method getAllCurrencies() is used on other js file i.e. exports.getBalance = async(req, res) => { try { const { ac } = req.decoded; let currency = await Balance.getAllCurrencies(ac); console.log("balance" , currency ) } catch (error) { console.log("error get balance=", error) } }
Error comes in above catch block i.e. inside getBalance API. This is the whole process.
@KumarUjjwal2022 please make a small public git repo that we can run and it shows the error reproducibly using only that small repo. Meaning, you should be able to make a small test app that shows the error. Then from there, I can take a look at it.
What node are you connected to? s1/s2.ripple.com don't support account_lines
@KumarUjjwal2022 please share which node you're using. Are you using a public server? If not, can you confirm that you're running your own rippled node?
No @intelliot , I'm not running my own node. I'm using xrpl public server , the cluster one and another s2.ripple.com. I have tried switching between these two full history cluster.
@intelliot I need help to setup admin connection with XRPL to perform different operation of NFTs. Could you explain process to make admin connection in Nodejs environment?
I have gone through this link i.e. https://xrpl.org/connect.html but I'm confused at setting up connection with XRPL as right now I'm using xrpl npm to connect with XRPL server. for eg my code is this:-
const xrpl = require("xrpl"); const client = new xrpl.Client(process.env.XRPL_URI, { connectionTimeout: 8000, });
await client.connect();
//CODE FOR DIFFERENT XRPL NFT OPERATION await client.disconnect();
So what are the changes i need to do and how?
@intelliot I need help to setup admin connection with XRPL to perform different operation of NFTs. Could you explain process to make admin connection in Nodejs environment?
I have gone through this link i.e. https://xrpl.org/connect.html but I'm confused at setting up connection with XRPL as right now I'm using xrpl npm to connect with XRPL server. for eg my code is this:-
const xrpl = require("xrpl"); const client = new xrpl.Client(process.env.XRPL_URI, { connectionTimeout: 8000, });
await client.connect();
//CODE FOR DIFFERENT XRPL NFT OPERATION await client.disconnect();
So what are the changes i need to do and how?
You can’t make admin connections to the mainnet servers.
What are you trying to accomplish? I can maybe help you figure it out.
@intelliot
Somewhere on google I saw suggestion to make admin connection to have multiple connect and disconnect with XRPL.
This is the link :- https://github.com/XRPLF/xrpl.js/issues/1055
As I get Websocket closed and related issues. So I want to make Admin connection. Mainly for which case we can have admin connection? As it is mentioned in XRPL docs.
@intelliot Somewhere on google I saw suggestion to make admin connection to have multiple connect and disconnect with XRPL. This is the link :- #1055
As I get Websocket closed and related issues. So I want to make Admin connection. Mainly for which case we can have admin connection? As it is mentioned in XRPL docs.
If you're being rate-limited, you'll need to run your own rippled node (instructions on how to do so are here). You can't get an admin connection for public nodes, like s1.ripple.com/s2.ripple.com/xrplcluster.com.
Okay @intelliot . Thanks for the clarification. You means if i have to setup admin connection first we need to setup our our node and then setup admin connection?
As I can observer that the NFT exchange on xrpl like Sologenic, Nftmaster, OnXRP etc doesn't have this connection issue. Does it means they have their on node setup?
As I can observer that the NFT exchange on xrpl like Sologenic, Nftmaster, OnXRP etc doesn't have this connection issue. Does it means they have their on node setup?
Yes, they do.
Okay , so we need to setup our node or cluster @mvadari ??
Okay , so we need to setup our node or cluster @mvadari ??
Yes
@intelliot I need help to setup admin connection with XRPL to perform different operation of NFTs. Could you explain process to make admin connection in Nodejs environment? I have gone through this link i.e. https://xrpl.org/connect.html but I'm confused at setting up connection with XRPL as right now I'm using xrpl npm to connect with XRPL server. for eg my code is this:- const xrpl = require("xrpl"); const client = new xrpl.Client(process.env.XRPL_URI, { connectionTimeout: 8000, });
await client.connect();
//CODE FOR DIFFERENT XRPL NFT OPERATION await client.disconnect(); So what are the changes i need to do and how?
You can’t make admin connections to the mainnet servers.
What are you trying to accomplish? I can maybe help you figure it out.
@justinr1234 Now I have ip for Node ,which can be used in below code :-
{ "method": "connect", "params": [ { "ip": "192.170.145.88", //this is not my ip, it is of xrpl docs "port": 51235 } ] }
Now if I want to connect to ripple server how can i in nodejs as I have mentioned in above comment that I'm confused how to use CONNECT Method , weather i need to connect to xrpl first and then need to hit this CONNECT method or something different?
What I mean is, what is the end goal you’re trying to accomplish? What are you building? What have you already built that is working?
What I mean is, what is the end goal you’re trying to accomplish? What are you building? What have you already built that is working?
I'm working on XRPL NFT marketplace. Currently I connect with xrpl by xrpl NPM for any kind of Transaction Type/ operations like minting NFT , creating offers etc. For this I use to connect with XRPL in this way:-
const xrpl = require("xrpl"); const client = new xrpl.Client(process.env.XRPL_URI, { connectionTimeout: 8000, });
await client.connect(); //CODE FOR DIFFERENT XRPL NFT OPERATION await client.disconnect();
but I think due to rate limit I need to have admin connection and own node setup. So I got ip from another team which is required for CONNECT method. So My query is how can i use this CONNECT method in nodejs environment as we have already one method to connect with xrpl server i.e. await client.connect(); . So what needs to be updated while making connection with xrpl server?
@KumarUjjwal2022 In order to say the node you'd like to connect to, you have to use it in the spot where currently you have process.env.XRPL_URI
.
A Client
object can only connect to one node, and so client.connect()
just tells it when to perform that connection. The actual ip is specified as a parameter in the constructor.
So your above code would look like:
const xrpl = require("xrpl");
const client = new xrpl.Client("YOUR NEW IP HERE", { connectionTimeout: 8000, });
await client.connect();
//CODE FOR DIFFERENT XRPL NFT OPERATION
await client.disconnect();
Make sure you include the port in the url - ex. 51233
in the websocket url for Testnet: wss://s.altnet.rippletest.net:51233/
Thanks @JST5000 one more help. Like I have to use only IP in project for making connection with xrpl and url including port should be configured/used on the other side from the party from whom I got IP address. Am I wright or wrong?
Like for making connection with XRPL in my project the code should be like this:- const xrpl = require("xrpl"); const client = new xrpl.Client("xxx.xxx.xxx.xxx", { connectionTimeout: 8000, });
await client.connect(); //CODE FOR DIFFERENT XRPL NFT OPERATION await client.disconnect();
And the url with port configuration should be their at IP providers end, Am I correct? I have to only use IP at my end for xrpl connect, Am I right or correct me if I'm wrong? As per my understanding if I'm using IP then I can't use url and the port should be used with url.
Also currenctly when I put IP on place of url I got this error:-
ValidationError: server URI must start with wss://
, ws://
, wss+unix://
, or ws+unix://
.
What does this mean, Either IP was not configured with xrpl url and port properly or what?
Hey @KumarUjjwal2022, my understanding of your questions are:
wss://127.0.0.1:51233
wss://
prefix instead of http://
or https://
prefix for your url. That indicates it's establishing a websocket connection instead of an http connection. (See above example for what the full ip string should look like)Thanks @JST5000 . I used in same way also but get this error :- NotConnectedError: self-signed certificate, data: Error: self-signed certificate, code: 'DEPTH_ZERO_SELF_SIGNED_CERT' -------------------error I'm getting. at the time of finding account_info and account_lines.
This is because the node you are hitting is using a self signed (aka snake oil) cert which is considered insecure.
If you have any futher issues I recommend seeking help at xrpldevs.org
Hi Team, I am using xrpl package to connect and fetching account_lines as well as account_info. It worked for few weeks now it gives Websocket error mentioned above. My code is gives below:-
/ Get accounts all XRP / async function getXrpBalance(ac) { await client.connect(); let response = await client.request({ method: "account_info", account: ac, ledger_index: "validated", }); await client.disconnect(); return { currency: "XRP", value: xrpl.dropsToXrp(response.result.account_data.Balance), }; }
/ get accounts all currencies/token / async function getIssuedCurrBalance(ac) { await client.connect(); let response = await client.request({ method: "account_lines", account: ac, ledger_index: "validated", }); await client.disconnect(); return response.result.lines.map((val) => ({ value: val.balance, currency: val.currency, issuer: val.account})); }
/ get accounts all balance / async function getAllCurrencies(ac) { const xrpBalance = await getXrpBalance(ac); const tokenBalance = await getIssuedCurrBalance(ac); tokenBalance.unshift(xrpBalance) return tokenBalance; }
getAllCurrencies(ac);
I have seen one issue similar to it i.e. #1185 & #1186 but didn't get what to do with this. Someone please help.