mirror of
https://github.com/asterisk/asterisk.git
synced 2026-06-23 08:49:21 -07:00
f9a38e1608
The websocket client proxy and server handshakes use ast_iostream_gets which are blocking calls. If the outgoing connection succeeds at the TCP or TLS layer but the proxy (if configured) or the websocket server fails to respond to the CONNECT or GET requests, the process can hang indefinitely and escalate to a deadlock. To address this, the handshakes are now guarded with calls to ast_iostream_set_timeout_sequence() with the timeout set to the client's (connection_timeout * 2) milliseconds. In order to use ast_iostream_set_timeout_sequence(), the iostream has to be set to non-blocking with ast_iostream_nonblock() but there was no way to reset the stream back to blocking mode so a new API ast_iostream_blocking() was added for it. Tracing was also enabled in the websocket_client_handshake function for future troubleshooting. Resolves: #1979