egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TCL HTTP: can't read "state(after)"

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Wed Mar 15, 2006 9:10 am    Post subject: TCL HTTP: can't read "state(after)" Reply with quote

I wonder if I do something wrong. Full error:
Code:
[-RO^Bot-] [12:58:59] #De_Kus# set errorInfo
[-RO^Bot-] Currently: can't read "state(after)": no such element in array
[-RO^Bot-] Currently:     while executing
[-RO^Bot-] Currently: "after cancel $state(after)"

This occurs with most (all?) asyncron HTTP requests I use in eggdrop. The general problem is obvious: after using ::http::cleanup $token, $state(after) has already been removed before its called by HTTP. But what else should I do? Do you believe using utimer 1 with that command would be a solution or rather a workaround? Is that an error of the HTTP package and should be reported to tcl.tk?

If greped this part of the script:
Code:
[-RO^Bot-] [14:02:58] tcl: evaluate (.tcl): exec grep after /usr/local/lib/tcl8.4/http2.5/http.tcl
[-RO^Bot-] Tcl:     catch {after cancel $state(after)}

no nice way imho, they could first check if exists state(after) to prevent occurance of unneccessary TCL errors.
This occurs at least till HTTP 2.5.2 from TCL 8.4.12.

Edit: not even after 60000 for http::cleanup or a set state(after) "" after the cleanup helps...
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Wed Dec 12, 2007 6:39 pm    Post subject: Reply with quote

I gather nothing further has been done to fix this (not that I'm surprised)?

De Kus: Did you lodge a bug report?
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Thu Dec 13, 2007 2:34 am    Post subject: Reply with quote

I've only seen that error when calling ::http::cleanup directly after an error test, like in:

Code:

catch {set page [::http::geturl $movieurl -timeout $::movietimeout]} error
   if {[string match -nocase "*couldn't open socket*" $error]} {
      puthelp "PRIVMSG $chan :Error: couldn't connect to filmspot.com..Try again later."
      ::http::cleanup $page
      return
   }
   if { [::http::status $page] == "timeout" } {
      puthelp "PRIVMSG $chan :Error: Connection to filmspot.com timed out..Try again later."
      ::http::cleanup $page
      return
   }
   set html [::http::data $page]

That's how I used to do my web procs. Now I just leave off the http::cleanup call.

I posted about the same error messages before, and was informed that http::cleanup is on a timer anyway, so calling it directly was unneeded. Haven't seen that error in the scripts I fixed that don't call http::cleanup (except at the end, after getting data.)

IOW, my newer scripts take the form:
Code:

catch {set page [::http::geturl $movieurl -timeout $::movietimeout]} error
   if {[string match -nocase "*couldn't open socket*" $error]} {
      puthelp "PRIVMSG $chan :Error: couldn't connect to filmspot.com..Try again later."
      return
   }
   if { [::http::status $page] == "timeout" } {
      puthelp "PRIVMSG $chan :Error: Connection to filmspot.com timed out..Try again later."
      return
   }
   set html [::http::data $page]
   ::http::cleanup $page
Back to top
View user's profile Send private message
Zircon
Op


Joined: 21 Aug 2006
Posts: 191
Location: Montreal

PostPosted: Thu Dec 13, 2007 4:12 am    Post subject: Reply with quote

Code:
<Anti-Flood> [03:06] #Owner# set errorInfo
<Anti-Flood> Currently: can't read "state(after)": no such element in array
<Anti-Flood> Currently:     while executing
<Anti-Flood> Currently: "after cancel $state(after)"
i always was trying to identify the script causing this error. So finally i understand it s related to the HTTP. Indeed, i use many scripts that deals with HTTP.
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Fri Dec 14, 2007 8:46 pm    Post subject: Reply with quote

De Kus wrote:
no nice way imho, they could first check if exists state(after) to prevent occurance of unneccessary TCL errors.
Testing this theory it seems to work...

lines 165,166 change to:
Code:
    if {[info exists state(sock)]} { catch {close $state(sock)} }
    if {[info exists state(after)]} { catch {after cancel $state(after)} }

lines 197,198 change to:
Code:
    if {[info exists state(sock)]} { catch {fileevent $state(sock) readable {}} }
    if {[info exists state(sock)]} { catch {fileevent $state(sock) writable {}} }

Using HTTP 2.4.2 and changing the lines above it seems to solve the problem. Running various http queries and a quick .set errrorInfo afterwards yields the following...
Quote:
<speechles> !g google
<sp33chy> 1,460,000,000 Results | Google @ http://www.google.com/ | Google Maps @ http://maps.google.com/ | Google Video @ http://video.google.com/ | Google Groups @ http://groups.google.com/
*meanwhile on the partyline directly after*
<speechles> .set errorInfo
<sp33chy> Currently: couldn't create error file for command: no such file or directory
<sp33chy> Currently: while executing
<sp33chy> Currently: "exec chmod 700 $nb_dir"

<speechles> !w .jasd asd
<sp33chy> Socket Error accessing 'jasd.wikipedia.org' .. Does it exist?
*meanwhile on the partyline directly after*
<speechles> .set errorInfo
<sp33chy> Currently: couldn't open socket: host is unreachable
<sp33chy> Currently: while executing
<sp33chy> Currently: "::http::geturl $query -timeout [expr 1000 * 5]"

Notice the top error message which is usually a state(after) error is instead an error message reporting no error found to report, so this does work as a fix. If someone can shed some light if this is indeed an http package bug it would be wonderful. Wink
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Fri Dec 14, 2007 11:47 pm    Post subject: Reply with quote

I use only one script that grabs data from the web (and causes this annoyance), the OV2 version of B0unTy's iMDB.tcl.

It uses:
Code:
::http::Finish $page

_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber