HttpRequest status -1

Monkey Targets Forums/Desktop/HttpRequest status -1

cgrossi(Posted March) [#1]
Hello, guys.

I'll go straight to the point: why am I getting status=-1 using HttpRequest? I'm working on a game for two player play online where I keep exchanging messages between them by a PHP page hosted on my site. But at some point, I start to get this status -1, wich means basicaly I lost my connection, which is not true. I've disabled my anti-virus, put MonkeyGame.exe on firewall list, but the problem remains...

What can it be??

Regards!!!!


Soap(Posted March) [#2]
Test with a different server setup? I believe that -1 means that the connection was refused.


cgrossi(Posted March) [#3]
What do you mean with a different server setup?


Soap(Posted March) [#4]
I mean there may be a problem with the site / server where the PHP page is hosted.


cgrossi(Posted March) [#5]
Uhm... I don't think that's the problem.. The site is ok. It's where I host my page.. Is it possible that I'm calling one send into the onhttprequestcomplete and for some reason it's getting lost??


Soap(Posted March) [#6]
Can you post a sample of the http code which reliably errors for you?

Test with this tool? https://requestb.in/


cgrossi(Posted March) [#7]
Hi, Soap.

Here is some code to illustrate what I'm doing, more or less... Hope you got it..
I'll try the tool you sent me, thanks!

Class Game Extends App Implements IOnHttpRequestComplete

    Field get_req:HttpRequest,update_php:Int[2],update:Bool
    
    Method OnHttpRequestComplete:Void(req:HttpRequest)
        Local responsetext:String=req.ResponseText()
        Local status:Int=req.Status()

        If responsetext.Contains("alt_conexao") Then
        	update_php[0]=2
        	update_php[1]=Millisecs()

                'calls one httprequest
	        get_req=New HttpRequest("GET",pagina+"?opcao=checa_mensagem,Self)
	        get_req.Send
        Endif


        If responsetext.Contains("checa_mensagem") Then
		'do some stuff and calls another httprequest
	        get_req=New HttpRequest("GET",pagina+"?opcao=atualiza_mensagem",Self)
	        get_req.Send
		update=false
	endif

    end method


    method OnCreate()
       	update_php[0]=2
       	update_php[1]=Millisecs()
       	update=False
    end method


    Method OnUpdate()

		If Not update Then
			If update_php[0]>0 Then
				If Millisecs()>update_php[1]+150 Then
					update_php[1]=Millisecs()
					update_php[0]-=1
					If update_php[0]=0 Then
						update=True
						get_req=New HttpRequest("GET",pagina+"?opcao=alt_conexao",Self )
  					        get_req.Send
    				        Endif
				Endif
			Endif
		Endif
    end method

end class