jfernandz / pyst2

A fork of the famous python pyst library for Asterisk.
137 stars 105 forks source link

Manager.logoff(): socket closed after writing "Action: Logoff" and before calling flush() #50

Closed SrMoreno closed 1 year ago

SrMoreno commented 4 years ago

In asterisk/manager.py, Manager class, When sending the "Logoff" action there seems to be a race condition where the socket can get closed after writing "Action: Logoff" in the socket and before calling flush. Then when flush is called a ValueError is raised.

It does not happens all the time, I tested introducing a delay between the writing and the flush, and the greater the delay, the higher the chance of the socket to be closed. My guess is that the connection is closed from the other side after receiving the "Logoff", and that sometimes it happens before the flush is called.