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

Automatically perform Logoff during the close call #121

Open
lisachenko opened this issue Dec 23, 2016 · 2 comments
Open

Automatically perform Logoff during the close call #121

lisachenko opened this issue Dec 23, 2016 · 2 comments

Comments

@lisachenko
Copy link

On a moderate usage of PAMI we can see errors like this:

PAMI\Client\Exception\ClientException: "Error reading''true"
 at ~/vendor_composer/marcelog/pami/src/mg/PAMI/Client/Impl/ClientImpl.php line 234

On the Asterisk side there will be errors:

ERROR[22439] utils.c: fwrite() returned error: Broken pipe
ERROR[22439] utils.c: fwrite() returned error: Broken pipe

I found an email with step-by-step guide how to solve this:

> AMI is a *two-way* protocol. You mustn't just fire in a bunch of commands
> and close the socket!
>
> The reason Asterisk reports the fwrite() error is because you have closed
> the socket before it had a chance to send you the responses.
>
> What you need to do is this:
>
> 1. Connect to the AMI port.
> 2. Read the one-line greeting message that Asterisk sends you. It will tell
>    you the version of the protocol (which might be of interest if you
> wanted
>    to be compatible with different versions of Asterisk).
> 3. Send the Login action with username, secret and terminating blank line.
> 4. Read the response lines from Asterisk until it gives you a blank line.
> 5. Send whatever command you want it to do, and go back to step 4.
> 6. When you have done the commands you want, send the Logoff action.
> 7. *** READ THE RESPONSE TO THE LOGOFF
> 8. Close the socket.

So, the issue is with Logoff method. I want to propose to add automatic sending of Logoff packet during the $pamiClient->close() call like with Login action in the $pamiClient->open(). This will prevent server from strange errors.

@fduch
Copy link

fduch commented Dec 23, 2016

If we do loggoff operation inside close we probably should be aware of #57

@lisachenko
Copy link
Author

Can be related to the #35

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