summaryrefslogtreecommitdiff
path: root/configs
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2014-06-26 12:21:14 +0000
committerMatthew Jordan <mjordan@digium.com>2014-06-26 12:21:14 +0000
commit365ae7523b45f18abb1418f498561cc2c8cbf680 (patch)
tree2d1ce4e889fedf5885299baef55a16df464f7a21 /configs
parentd171e0b2e96ca1cc2cf6c53cdd9d5a3c876be91b (diff)
res_http_websocket: Close websocket correctly and use careful fwrite
When a client takes a long time to process information received from Asterisk, a write operation using fwrite may fail to write all information. This causes the underlying file stream to be in an unknown state, such that the socket must be disconnected. Unfortunately, there are two problems with this in Asterisk's existing websocket code: 1. Periodically, during the read loop, Asterisk must write to the connected websocket to respond to pings. As such, Asterisk maintains a reference to the session during the loop. When ast_http_websocket_write fails, it may cause the session to decrement its ref count, but this in and of itself does not break the read loop. The read loop's write, on the other hand, does not break the loop if it fails. This causes the socket to get in a 'stuck' state, preventing the client from reconnecting to the server. 2. More importantly, however, is that the fwrite in ast_http_websocket_write fails with a large volume of data when the client takes awhile to process the information. When it does fail, it fails writing only a portion of the bytes. With some debugging, it was shown that this was failing in a similar fashion to ASTERISK-12767. Switching this over to ast_careful_fwrite with a long enough timeout solved the problem. Note that this version of the patch, unlike r417310 in Asterisk 11, exposes configuration options beyond just chan_sip's sip.conf. Configuration options to configure the write timeout have also been added to pjsip.conf and ari.conf. #ASTERISK-23917 #close Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/3624/ ........ Merged revisions 417310 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 417311 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@417317 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'configs')
-rw-r--r--configs/ari.conf.sample31
-rw-r--r--configs/pjsip.conf.sample8
-rw-r--r--configs/sip.conf.sample6
3 files changed, 32 insertions, 13 deletions
diff --git a/configs/ari.conf.sample b/configs/ari.conf.sample
index decdddc58..59f9a44e5 100644
--- a/configs/ari.conf.sample
+++ b/configs/ari.conf.sample
@@ -1,19 +1,25 @@
[general]
-enabled = yes ; When set to no, ARI support is disabled.
-;pretty = no ; When set to yes, responses from ARI are
-; ; formatted to be human readable.
-;allowed_origins = ; Comma separated list of allowed origins, for
-; ; Cross-Origin Resource Sharing. May be set to * to
-; ; allow all origins.
-;auth_realm = ; Realm to use for authentication. Defaults to Asterisk
-; ; REST Interface.
+enabled = yes ; When set to no, ARI support is disabled.
+;pretty = no ; When set to yes, responses from ARI are
+; ; formatted to be human readable.
+;allowed_origins = ; Comma separated list of allowed origins, for
+; ; Cross-Origin Resource Sharing. May be set to * to
+; ; allow all origins.
+;auth_realm = ; Realm to use for authentication. Defaults to Asterisk
+; ; REST Interface.
+;
+; Default write timeout to set on websockets. This value may need to be adjusted
+; for connections where Asterisk must write a substantial amount of data and the
+; receiving clients are slow to process the received information. Value is in
+; milliseconds; default is 100 ms.
+;websocket_write_timeout = 100
;[username]
-;type = user ; Specifies user configuration
-;read_only = no ; When set to yes, user is only authorized for
-; ; read-only requests.
+;type = user ; Specifies user configuration
+;read_only = no ; When set to yes, user is only authorized for
+; ; read-only requests.
;
-;password = ; Crypted or plaintext password (see password_format).
+;password = ; Crypted or plaintext password (see password_format).
;
; password_format may be set to plain (the default) or crypt. When set to crypt,
; crypt(3) is used to validate the password. A crypted password can be generated
@@ -22,3 +28,4 @@ enabled = yes ; When set to no, ARI support is disabled.
; When set to plain, the password is in plaintext.
;
;password_format = plain
+
diff --git a/configs/pjsip.conf.sample b/configs/pjsip.conf.sample
index 1bcfcb96b..3aa05a96b 100644
--- a/configs/pjsip.conf.sample
+++ b/configs/pjsip.conf.sample
@@ -616,7 +616,13 @@
; "")
;tos=0 ; Enable TOS for the signalling sent over this transport (default: "0")
;cos=0 ; Enable COS for the signalling sent over this transport (default: "0")
-
+;websocket_write_timeout=100 ; Default write timeout to set on websocket
+ ; transports. This value may need to be adjusted
+ ; for connections where Asterisk must write a
+ ; substantial amount of data and the receiving
+ ; clients are slow to process the received
+ ; information. Value is in milliseconds; default
+ ; is 100 ms.
;==========================CONTACT SECTION OPTIONS=========================
;[contact]
diff --git a/configs/sip.conf.sample b/configs/sip.conf.sample
index 1175047b3..010137d72 100644
--- a/configs/sip.conf.sample
+++ b/configs/sip.conf.sample
@@ -229,6 +229,12 @@ tcpbindaddr=0.0.0.0 ; IP address for TCP server to bind to (0.0.0.0
; unauthenticated sessions that will be allowed
; to connect at any given time. (default: 100)
+;websocket_write_timeout = 100 ; Default write timeout to set on websocket transports.
+ ; This value may need to be adjusted for connections where
+ ; Asterisk must write a substantial amount of data and the
+ ; receiving clients are slow to process the received information.
+ ; Value is in milliseconds; default is 100 ms.
+
transport=udp ; Set the default transports. The order determines the primary default transport.
; If tcpenable=no and the transport set is tcp, we will fallback to UDP.