Closed Noksa closed 3 years ago
I will take a look later. But before, here is a little tip for your golang code. CallRPCWithTimeout - variadic function and you don't need to use these if/else statements. Just unfold args...
rpc.process.CallRPCWithTimeout(8, node, module, f, args...)
so your code should be like
for i := 0; i < 5; i++ {
res, err = rpc.process.CallRPCWithTimeout(8, node, module, f, args...)
// handle res and err variables
}
May I ask you to provide more detail on how to reproduce this behavior? And what version of Golang do you use? I'm asking about versions because there were few problems with the Golang Timer under the hood (in 1.4.0 and 1.4.1, in 1.6.0 AFAIK had another problem with the timer).
Sure! I’ll provide an example in a few days, I’m just on holidays now.
You can try to reproduce this error as follows (I tried it on Mac): 1) Install erlang@22 via homebrew (brew install erlang@22) 2) Run an erlang node using the following command (just change YOUR_HOST_NAME placeholder):
➜ ~ /usr/local/opt/erlang@22/bin/erl -sname demo@YOUR_HOST_NAME -setcookie 123
3) Checkout a code from here: https://github.com/Noksa/erlang-test
4) Build it via go build
5) Run it using the following flags (just change YOUR_HOST_NAME placeholder):
./erlang-test -name test@YOUR_HOST_NAME -target demo@YOUR_HOST_NAME -trace.dist -trace.node
6) Wait a bit or run it again and eventually you will receive the error. I receive this error after 20-30 seconds:
2021/05/10 15:24:37 [test@MBP-Alexandr] RPC calling: demo@MBP-Alexandr:erlang:statistics
2021/05/10 15:24:37 [test@MBP-Alexandr] sending message by tuple [rex demo@MBP-Alexandr]
2021/05/10 15:24:37 Node control: etf.Tuple{2, "", etf.Pid{Node:"test@MBP-Alexandr", ID:0x3eb, Serial:0x1, Creation:0x1}}
2021/05/10 15:24:37 [test@MBP-Alexandr] sending message by pid {test@MBP-Alexandr 1003 1 1}
2021/05/10 15:24:37 [test@MBP-Alexandr]. {test@MBP-Alexandr 1003 1 1} got message from etf.Pid{Node:"", ID:0x0, Serial:0x0, Creation:0x0}
2021/05/10 15:24:37 got reply: etf.Ref{Node:"test@MBP-Alexandr", Creation:0x1, ID:[]uint32{0x60f9, 0x59f6, 0x0}}
etf.Tuple{etf.Ref{Node:"test@MBP-Alexandr", Creation:0x1, ID:[]uint32{0x60f9, 0x59f6, 0x0}}, etf.Tuple{5888085, 158}}
2021/05/10 15:24:37 Result: [5888085 158]
2021/05/10 15:24:37 [test@MBP-Alexandr] RPC calling: demo@MBP-Alexandr:erlang:statistics
2021/05/10 15:24:37 [test@MBP-Alexandr] sending message by tuple [rex demo@MBP-Alexandr]
2021/05/10 15:24:37 Error: timeout, Result: <nil>
thanks a lot for the details. what is the golang version?
1.16
I meant what exact version :). Please, show the output of
go version
@halturin Oh sorry, I misunderstood you :)
➜ ~ go version
go version go1.16.2 darwin/amd64
Thanks for the patience. Its really nice catch. Just merged a fix and made a new release tag. here is PR https://github.com/halturin/ergo/pull/48
@halturin Awesome!
Hello again :)
I've found an unexpected behavior when I run RPC Calls from golang to an erlang node.
Please help me to understand why it happens. Thanks.
You can find the log from go below. As you may see sometimes for some RPC call command the timeout error is returned instantly after calling RPC for no reason (I have 8 seconds timeout)
I've created a func to retry failed calls but it's just a workaround: