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

Logoff inconsistant behaviour #14

Open
faheem2084 opened this issue Mar 6, 2019 · 2 comments
Open

Logoff inconsistant behaviour #14

faheem2084 opened this issue Mar 6, 2019 · 2 comments

Comments

@faheem2084
Copy link

faheem2084 commented Mar 6, 2019

I'm trying to connect with Asterisk AMI interface using goAMI. I am sequentially calling, connect, originate and logoff functions. All looks fine but i face strange behavior with logoff function.
If I call the script and call ami.logoff() function for first time it will return the nil value which seems fine. When I call the same script for the second time, this functions return expected.

Code block

res := ami.Logoff(socket, uuid)
if res == nil {
	println("Logoff successful", res)
} else {
	println("Logoff failed", res)
}

Output when calling the same script for two times.

$ go run main.go
Logoff successful (0x0,0x0)
$ go run main.go
Logoff failed (0x114ca00,0xc000012070)

Asterisk version: 11.25.3
OS: CentOS 7.4

@mariemec
Copy link

mariemec commented Jul 5, 2021

I was having this same issue! I forked the repo locally and changed the Socket.go file. I updated the socket's "incoming" chan to be un-buffered by removing the size parameter. This allows for the Recv function to be able to finish reading s.incoming when the TCP connection is closed (instead of raising an EOF error).

	s := &Socket{
		...
		incoming: make(chan string),
		...
	}

@mind-ar
Copy link
Contributor

mind-ar commented Jul 6, 2021

Hello, the issue should be resolved in PR #31, which is awaiting approval.
The source of the problem is in the "send" function, which does not wait for the response to the "action-id" of the command. When the Logout command is executed, AMI sends event messages. depending on the order in which those events are received the error will occur

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

Successfully merging a pull request may close this issue.

3 participants