Hello everybody. I'm fairly new to IRC scripting, but have the hang of it a bit. I'm having an issue with a couple of my scripts, they aren't returning the information obtained via the socket request. Sometimes it works, sometimes it doesn't. Fairly annoying when users are trying to run the script but it decides not to work for half an hour.

Am I doing something wrong here? Like I said, it works somemtimes but not all of the time. It tends to work for a couple of minutes then stops for 30 minutes or so. I don't understand it...

Code:
; ---------- CHECK MANAPOTS ----------

alias checkmp {
  if ($sock(CheckManaPots)) sockclose CheckManaPots
  set %manapot.check $1 $+ , $+ %manapot.check
  timerCHECKMP off
  timerCHECKMP 1 5 sockopen CheckManaPots d3sanc.com 80
}

on *:TEXT:!mp:#: {
  /checkmp $nick
}

on *:TEXT:!mp *:#: {
  if($nick == manapot) {
    /checkmp $2
  }
}

on *:TEXT:!manapots:#: {
  /checkmp $nick
}

on *:TEXT:!manapot:#: {
  /checkmp $nick
}

on *:sockopen:CheckManaPots: {
  sockwrite -n $sockname GET /db/manabot/manapots.php?id= $+ %manapot.check $+ &action=check HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
  sockwrite -n $sockname Host: d3sanc.com
  sockwrite -n $sockname Accept-Language: en-us
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname
}

on *:sockread:CheckManaPots: {
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temp
    sockread -f %temp
    if (ManaPots isin %temp) {
      msg #manapot %temp
      set %manapot.check
    }
  }
}