Sign In Register

How can we help you today?

Start a new topic
Answered

SparkHttp timeout

Hi, what is default setup for request timeout time for Spark.getHttp(url)->http.postJson(json) ?



Best Answer

Hi Marcin,


The SparkHTTP timeout isn't strictly defined but does adhere to the timeout of script executions on the platform, which is approx 30 seconds.


-Pádraig


Answer

Hi Marcin,


The SparkHTTP timeout isn't strictly defined but does adhere to the timeout of script executions on the platform, which is approx 30 seconds.


-Pádraig

How to explicitly define it? 30s for an HTTP timeout means your entire call will timeout with 0 error info even for a simple ping/pong request, if the other side times out.


Surely there must be a way? For example, right now, our entire game is offline while I skip a simple ping/pong request while our server is down.


Even then, the default *should* be explicitly defined to a max of 10s, if not 5s: How am I supposed to even handle the error?

Example in Current State:


  1. I call my optional API with a ping/pong to check isOnline - if offline, I'd just skip it.
  2. http gets stuck on GET until the script (not http call), itself, times out!
  3. Not only does the script timeout for this optional check, the error is simply { "error" : "timed out" }, not even allowing you to leave further diagnostic info.
  4. If I were able to leave a timeout, I could skip it if no response instead of timing out the entire script (which is gamebreaking).
  5. If I were able to leave a timeout, I could add additional error information to properly debug.
  6. If I were able to leave a timeout, I could send a webhook to myself to let me know that x service is out instead of trying to debug a vague timeout error.
  7. If I were able to leave a timeout, 3rd-party API calls that have maintenance or outages won't 100% block your GS scripts.This would further lead to less CPU time locked, leading to more $$ GS would save.

It's very standard to set a low timeout for HTTP calls: That said, this is not a feature request, but a question for either a fix or workaround: 

A) @ GS: My friends, can you please, please fix the timeout timer (and preferably set the default to ~3 to 5s like most other folks do)? There's no reason why a no-response API call should block an entire script without any way to handle it.

B) Meanwhile, how to workaround HTTP call timeouts? I tried testing a few creative ways, but alas, no dice.

Script timeouts are 10 seconds now. I would just limit that API call to only handle the SparkHttp. If you get a timeout, the HTTP Post failed. If you dont, handle the rest of the logic from that response point. However, why cant the client handle the HTTP Post separate from GameSparks?

A custom timeout (in milliseconds) can be passed as an additional argument, like:

var httpSender = Spark.getHttp("http://somehost”, 10000);


Note that he actual response from a 'Spark.getHttp("http://somehost”, 1000).get()' is null (if timeout is triggered)

Login to post a comment