0

I'm working on a frontrunning bot using Nethereum. the problem I'm facing is the following, once I get all the pending transaction hashes through the websocket, I pass the hash trhough EthGetTransactionByHash to get its details and two scenarios happen: if I declare one web3 or websocketclient instance and use it for all the EthGetTransactionbyHash requests, I end up very quickly getting the details too late(transaction already validated). On the other hand, If I create one instance of web3 or websocketclient per EthGetTransactionbyHash request, it becomes very fast, which is nice, but after few seconds it starts generating Nethereum.JsonRpc.Client.RpcClientTimeoutException: Rpc timeout after 20000 milliseconds ---> System.Threading.Tasks.TaskCanceledException. AND Nethereum.JsonRpc.Client.RpcClientUnknownException: Error occurred when trying to web socket requests(s): eth_getTransactionByHash ---> System.OperationCanceledException: the operation was cancelled). so far, I haven't made any major coding, it's just the websocket and streaming tutorial https://docs.nethereum.com/en/latest/nethereum-subscriptions-streaming/ plus eth_getTransactionByHash for each hash detected, nothing more

1 Answer 1

0

I found the solution, what I have done, I created a concurentQueue that I populated with 100 web3geth variables (it only works with web3geth and the RPC URL, don't ask me why :-p ). then I use each entry for one request via dequeue, once it is dequeued and used, I enqueue it again so concurentqueue remains populated without having to create any new variables. I tested the app for 5 minutes and it didn't raise the exception once. so you can keep it in mind for future reference if someone else asks. PS the ethgettransactionbyHash also needs to be launched in a new thread.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.