Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second CallRPC method is stuck when it is called against remote erlang node #120

Closed
Noksa opened this issue Dec 1, 2022 · 3 comments
Closed

Comments

@Noksa
Copy link

Noksa commented Dec 1, 2022

Describe the bug
I can't do CallRPC to remote erlang node more than one time.
The second CallRPC is stuck due to this line in the code:

sp.callbackWaitReply <- &ref

To Reproduce
Steps to reproduce the behavior:

Probably, I'm doing something wrong, but there is no documentation for this case.

My code:

func CreateNewNode() *ErlangHelper {
	eh := new(ErlangHelper)
	opts := node2.Options{}

	// Initialize new node with given name, cookie, listening port range and epmd port
	node, err := ergo.StartNode(configuration.Cfg.SelfNodeFullName, configuration.Cfg.Cookie, opts)
	if err != nil {
		panic(err)
	}
	// Initialize new instance of demoGenServ structure which implements Process behaviour
	_, _ = node.Spawn("exporter", gen.ProcessOptions{}, eh)
	return eh
}

type ErlangHelper struct {
	gen.Server
	ErlangProcess
}

type ErlangProcess struct {
	*gen.ServerProcess
}

func (eh *ErlangHelper) Init(process *gen.ServerProcess, args ...etf.Term) error {
	demo := &ErlangProcess{
		ServerProcess: process,
	}
	// do not inherit parent State
	demo.State = nil

	//if err := process.Behavior().(DemoBehavior).InitDemo(demo, args...); err != nil {
	//	return err
	//}
	process.State = demo
	eh.ServerProcess = process
	return nil
}

func (eh *ErlangHelper) HandleInfo(process *gen.ServerProcess, message etf.Term) gen.ServerStatus {
	return gen.ServerStatusOK
}

func (eh *ErlangHelper) CallRPC(node string, module string, f string, args ...etf.Term) etf.Term {
	log.Debugf("Calling RPC to %v, module %v, func %v, args %v", node, module, f, args)
	res, err := eh.ServerProcess.CallRPCWithTimeout(1, node, module, f, args...)
	if err != nil {
		panic(err)
	}
	return res
}

When I do CallRPC first time, it works, I receive information from an erlang (23) node.

But the second one is stuck, because no one reads sp.callbackWaitReply channel in the second call (I don't know why).

The only one thins that I need is send RPCs to another erlang nodes.

What I've missed? Thanks.

Expected behavior
RPC calls work

Screenshots

Environment (please complete the following information):

  • Arch: aarch64
  • OS: Mac
  • Framework Version 2.2.0
  • 10
@Noksa Noksa changed the title Is there a chance to get CallRPC working to remote node? Second CallRPC method is stuck when it is called against remote erlang node Dec 1, 2022
@halturin
Copy link
Collaborator

halturin commented Dec 1, 2022

Thanks for reporting this issue. I'll take a look.

@Noksa
Copy link
Author

Noksa commented Dec 1, 2022

Let me know if you need more details.
Probably, I can provide a project where you can reproduce it.

I didn't want to create the issue because I'm still not sure that it is not my fault :)

@halturin
Copy link
Collaborator

halturin commented Mar 1, 2023

Erlang RPC support has been removed in v.2.2.2

@halturin halturin closed this as completed Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants