- Home /
ERROR SAME REQUEST WITHIN A SECOND: 4
I am trying to upload a high score to dreamlo and am getting an error. "ERROR SAME REQUEST WITHIN A SECOND: 4 UnityEngine.MonoBehaviour:print(Object) HighScoreManager:FormatHighscores(String) (at Assets/Scripts/HighScoreManager.cs:68) d__10:MoveNext() (at Assets/Scripts/HighScoreManager.cs:52) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)"
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
public class HighScoreManager : MonoBehaviour
{
const string privateCode = "";
const string publicCode = "";
const string webURL = "http://dreamlo.com/lb/";
DisplayHighScore highscoreDisplay;
public Highscore[] highscoresList;
static HighScoreManager instance;
void Awake()
{
highscoreDisplay = GetComponent<DisplayHighScore>();
instance = this;
}
public static void AddNewHighscore(string username, int score)
{
instance.StartCoroutine(instance.UploadNewHighscore(username, score));
}
IEnumerator UploadNewHighscore(string username, int score)
{
WWW www = new WWW(webURL + privateCode + "/add/" + UnityWebRequest.EscapeURL(username) + "/" + score);
yield return www;
if (string.IsNullOrEmpty(www.error))
{
print("Upload Successful");
DownloadHighscores();
}
else
{
print("Error uploading: " + www.error);
}
}
public void DownloadHighscores()
{
StartCoroutine("DownloadHighscoresFromDatabase");
}
IEnumerator DownloadHighscoresFromDatabase()
{
WWW www = new WWW(webURL + publicCode + "/pipe/");
yield return www;
FormatHighscores(www.text);
highscoreDisplay.OnHighscoresDownloaded(highscoresList);
}
void FormatHighscores(string textStream)
{
string[] entries = textStream.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
highscoresList = new Highscore[entries.Length];
for (int i = 0; i < entries.Length; i++)
{
string[] entryInfo = entries[i].Split(new char[] { '|' });
string username = entryInfo[0];
int score = int.Parse(entryInfo[1]);
highscoresList[i] = new Highscore(username, score);
print(highscoresList[i].username + ": " + highscoresList[i].score);
}
}
}
public struct Highscore
{
public string username;
public int score;
public Highscore(string _username, int _score)
{
username = _username;
score = _score;
}
}
I have tried looking for a solution and have not found anything.
Isn't the error explicit enough? You are perfor$$anonymous$$g the same request multiple a times within a single second and the web service you use does not seem to like this.
I have tied to slowing it down with a wait before and after but it still gives that same error.
Answer by ma69kra · Jul 29, 2021 at 05:20 AM
@kailanadams02 did you find any solution for this issue? edit - i found a fix replace /pipe/ with /pipe
Yes, I found a solution, different than the one you have found. I just slowed the number of times it is requesting the data.