httprequest timeouts

Monkey Forums/Monkey Programming/httprequest timeouts

Xaron(Posted 2013) [#1]
Hi all,

just a short question about http requests: How does Monkey handle timeouts? The callback just never gets called, right?

Can I just fire another request over and over again? When does it get closed?

Cheers!


Markus(Posted 2013) [#2]
at timeout i would expect a req.Status in OnHttpRequestComplete.
a closed at Complete.
calling the same request before the last ans simular get a feedback make no sense.
just turn off your router or modem and see what happens.
i guess there is a default timeout time or direct feedback.
i think a timeout is a network error too.
"If a network error occured, the request status will be -1."


Xaron(Posted 2015) [#3]
Actually no, it never returns. Just tried it on my Android device and it waits forever.

So Mark, could you have a look at this please?

Oh and it would be nice if you would add the option to set the timeout value (e.g for Android:
_con.setConnectTimeout(timeout);
_con.setReadTimeout(timeout);


Xaron(Posted 2015) [#4]
Well I think I'm gonna to rewrite this module as it's necessary to check for the connection state as well. That's one reason btw why the timout doesn't work. If there is no connection at all there won't be a timeout...


Xaron(Posted 2015) [#5]
Solution for Android:

change httprequest.android.java method "open":
	void Open( String req,String url )
	{
		_response="";
		_status=-1;
		_recv=0;
		try
		{
			ConnectivityManager connMgr = (ConnectivityManager)BBAndroidGame.AndroidGame().GetActivity().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
			NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
			if( networkInfo != null && networkInfo.isConnected() )
			{
				URL turl=new URL( url );
				_con=(HttpURLConnection)turl.openConnection();
				_con.setRequestMethod( req );
				_con.setConnectTimeout(5000);
				_con.setReadTimeout(5000);
				_status = 1;
			}
		}
		catch( Exception ex )
		{
		}		
	}