} elseif {$http_status == "timeout"} {
sendmsg # "\002\00304\[ERROR\]\002\003 \002Connection timed out - $the_url ... Retrying ..."
set http_data [::http::data $http_handle]
::http::cleanup $http_handle
set File [::mysql::escape [getPage $the_url]]
.....
proc getPage { the_url } {
::http::register https 443 ::tls::socket
set token [::http::geturl $the_url -binary 1 -timeout 10000]
set data [::http::data $token]
::http::cleanup $token
return $data
}
As u can see i have a timeout of 10s in the getPage proc. What i'm looking for is that this part:
set File [::mysql::escape [getPage $the_url]]
would be called for eg lets say 20 seconds later, instead of needing/using such a high timeout in my getPage proc. Everything ive tried till yet ended up in errors :/
I would not recommend using the after command in blocking mode, as eggdrop is single-threaded, and blocking behavior prevents the eggdrop from taking any actions at all during the block.
I'd rather recommend using the utimer command to schedule a piece of code to be executed at a later time, or if possible, use the -command option with your http-request to use an event-driven mode:
::http::register https 443 ::tls::socket
if {![catch {set http_handle [http::geturl $the_url -binary 1 -timeout $::check(timeout)]} error]} {
set http_status [http::status $http_handle]
if {$http_status == "ok"} {
if {[http::ncode $http_handle] == 200} {
set http_data [::http::data $http_handle]
::http::cleanup $http_handle
set File [::mysql::escape $http_data]
::mysql::encoding $db_handle binary
set sql [::mysql::sel $db_handle "INSERT INTO ...
}
} elseif {$http_status == "timeout"} {
sendmsg $channel "\002\00304\[ERROR\]\002\003 \002Connection timed out - $the_url ... Retrying ..."
set http_data [::http::data $http_handle]
::http::cleanup $http_handle
set File [::mysql::escape [getPage $the_url]]
::mysql::encoding $db_handle binary
set sql [::mysql::sel $db_handle "INSERT INTO...
} elseif {[http::ncode $http_handle] == 404} {
The first part, as shown here, uses a timeout of 3 seconds. In case of timeout, ur example code should retry xx seconds delayed, but i dunno the best way to use it. May u please help
Elfriede,
What you need to do, is to split your proc up into several pieces, thus allowing you to call the second http-transaction separately from the first one using a timer.