Hi here,
I’m a newbie on Asterisk, and after a long time research I’ve gotten my Asterisk server work with CURL. But there are still some problems that I’m trying to resolve.
Could anyone here help me?
-
I configured the Asterisk server to real-timely seek SIP peers from my HTTP server via CURL. The CURL will hold the TCP connection if I keep the connection alive, and that would result in a block when the connection has not been activated long time. As a consequence, any requests from SIP clients would be blocked for a long time until the connection is thought as closed(the default value is 180s). So I have to turn the keep-alive option off at my HTTP server end. But I do not think this is the best way to deal with it.
-
I’ve read some source of Asterisk about real-time with CURL. And I do figure out that Asterisk only hold one CURL handle despite multiple threads, which results in that Asterisk deals with requests in parallel but has to make a WEB request (for real-timely load SIP peers) serially. And obviously, it makes the server slowly.
There are nearly no messages about Asterisk with CURL. Questions above are summarized after a lot of trials.
The version of my Asterisk is 11.3.0. Does anyone here know anything about these problems? Thanks.
Ailen
Hi
have you looked at teh curlopt function ?
[code] -= Info about function ‘CURLOPT’ =-
[Synopsis]
Set options for use with the CURL() function
[Description]
cookie - Send cookie with request [none]
conntimeout - Number of seconds to wait for connection
dnstimeout - Number of seconds to wait for DNS response
ftptext - For FTP, force a text transfer (boolean)
ftptimeout - For FTP, the server response timeout
header - Retrieve header information (boolean)
httptimeout - Number of seconds to wait for HTTP response
maxredirs - Maximum number of redirects to follow
proxy - Hostname or IP to use as a proxy
proxytype - http, socks4, or socks5
proxyport - port number of the proxy
proxyuserpwd - A : to use for authentication
referer - Referer URL to use for the request
useragent - UserAgent string to use
userpwd - A : to use for authentication
ssl_verifypeer - Whether to verify the peer certificate (boolean)
hashcompat - Result data will be compatible for use with HASH()
[Syntax]
CURLOPT()
[/code]
You can set the timeouts here, so its not using 180s, we had to change the source some years agao because of the 180s problem on a customer server.
Thanks for your aply. I did this in another way(with 30s hard code~~), and that made it better but not the best. Because the TCP connection can be thought as closed after 30s, but during that time, clients also will be blocked. The better result is that the service will be available more shortly.
By the way, do you have any ideas on add more threads for CURL? So that I can do a faster request.
Thanks again.
Ailen~
[quote=“ianplain”]Hi
have you looked at teh curlopt function ?
[code] -= Info about function ‘CURLOPT’ =-
[Synopsis]
Set options for use with the CURL() function
[Description]
cookie - Send cookie with request [none]
conntimeout - Number of seconds to wait for connection
dnstimeout - Number of seconds to wait for DNS response
ftptext - For FTP, force a text transfer (boolean)
ftptimeout - For FTP, the server response timeout
header - Retrieve header information (boolean)
httptimeout - Number of seconds to wait for HTTP response
maxredirs - Maximum number of redirects to follow
proxy - Hostname or IP to use as a proxy
proxytype - http, socks4, or socks5
proxyport - port number of the proxy
proxyuserpwd - A : to use for authentication
referer - Referer URL to use for the request
useragent - UserAgent string to use
userpwd - A : to use for authentication
ssl_verifypeer - Whether to verify the peer certificate (boolean)
hashcompat - Result data will be compatible for use with HASH()
[Syntax]
CURLOPT()
[/code]
You can set the timeouts here, so its not using 180s, we had to change the source some years agao because of the 180s problem on a customer server.[/quote]