Quantcast
Channel: Questions in topic: "webrequest"
Viewing all 387 articles
Browse latest View live

Why do iOS web requests stop working after a few hours?

$
0
0
I build my app to iOS and all my requests and asset bundles work perfectly. I can do this over and over but when I leave the phone alone and come back in a few hours the app no longer works. I get (Filename: currently not available on il2cpp Line: -1) in the log. -I am clearing the cache at start up in case that was the issue but it's not. -Im not saving any bundles, paths, or content -I have disabled strip engine code As I said before everything works perfect no errors for a while and then just stops as if the app expires or something. I do have a paid developer account so that should not be an issue. Documents and data stay at the same amount of memory no matter how many time I open and close the app so I don't see anything leaking there either.

SSLHandshakeException during Web Request

$
0
0
I was working on the game and as per game requirements, I was fetching logos from the web server through Web Request. Here is my code: // fetching all company related details IEnumerator LoadCompanyDetails () { WWW www = new WWW (GameConstants.API_GET_LOGOS); yield return www; if (www.error == null) { // Debug.Log ("Data: " + www.text); JSONObject jsonObj = new JSONObject (www.text); Debug.Log ("Loaded following XML " + www.text); long status = jsonObj [TAG_STATUS].i; if (status == 1) { // login success List dataObj = jsonObj [TAG_DATA].list; for (int i = 0; i < dataObj.Count; i++) { Company companyItem = new Company (); JSONObject companyObj = dataObj [i]; companyItem.CompanyId = companyObj [TAG_COMPANY_ID].i.ToString (); companyItem.CompanyName = companyObj [TAG_COMPANY_NAME].str; companyItem.CompanyLogoUrl = companyObj [TAG_COMPANY_LOGO].str; companyItem.AbountCompany = companyObj [TAG_COMPANY_ABOUT].str; companyItem.ContactInfo = companyObj [TAG_COMPANY_CONTACT_INFO].str; companyItem.CompanyEmail = companyObj [TAG_COMPANY_EMAIL].str; companyItem.CompanyWebsite = companyObj [TAG_COMPANY_WEBSITE].str; DataCollection.companyDetailsList.Add (companyItem); } StartCoroutine (FetchCompanyLogos ()); } else { // login fail } } else { Debug.Log ("++++++++++++++++++++++++++++++"); Debug.Log ("Error: " + www.error); } } Last 3 months this working properly but suddenly SSLHandshakeException started to come. ![alt text][1] On PC its running properly, request get satisfied. On mobile device, its not working now. Give me some suggestion for solution in this. [1]: /storage/temp/126615-sslhandshakeexception.png

www request Error unity 2018

$
0
0
Hi, I am working on webservices where I have to send the image(binary data) to server. I am unable to connect to the server when I start playing unity editor, which says "WWW Error: Unable to complete SSL connection ", I am using unity 2018.2f1. Please let us know if anyone has a solution for this. Thank you.

WebException: Error: NameResolutionFailure

$
0
0
**I added the Gamesparks SDK and after that when I tried to create a new game on gamesparks but this error keep showing in my console.** WebException: Error: NameResolutionFailure System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) System.Net.HttpWebRequest.GetRequestStream () System.Net.WebClient.UploadDataCore (System.Uri address, System.String method, System.Byte[] data, System.Object userToken) System.Net.WebClient.UploadData (System.Uri address, System.String method, System.Byte[] data) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115) UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:262) UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:255) UnityEditor.HostView.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:84)

Issue with sending Json via UnityWebRequest

$
0
0
Hello! I want to send a simple JSON string to the Google Perspective API via UnityWebRequest. Everything seems to be working fine, but there seems to be a problem with my string. I always get an error saying *"Invalid JSON payload received. Unknown name \"{comment:{text:\"Test\"},requestedAttributes:{TOXICITY:{}}}\": Cannot bind query parameter. Field '{comment:{text:\"Test\"},requestedAttributes:{TOXICITY:{}}}' could not be found in request message."*. Here's my code: IEnumerator MakeCall(){ string url = "https://commentanalyzer.googleapis.com/v1alpha1/comments:analyze?key=XXXXXXX"; string requestJson = "{comment:{text:\"Test\"},requestedAttributes:{TOXICITY:{}}}"; UnityWebRequest uwr = UnityWebRequest.Post(url, requestJson); yield return uwr.SendWebRequest(); if (uwr.isNetworkError) { Debug.Log("Error While Sending: " + uwr.error); } else { Debug.Log("Received: " + uwr.downloadHandler.text); } } When I try to send the same string via curl command in terminal, it seems fine and I get my answer from the API. Can anybody tell me where the problem could be? Thanks!

How do I get into my StreamingAssets folder for the Web?

$
0
0
I'm working on a project where I need to access the StreamingAssets folder on a Webgl build. I've done it for mobile and PC. When it comes to web builds, I'm still learning the differences. I know that I need to perform a webrequest but I don't know how to find the url.

Objectives:
  1. Understanding the proper way to FIND the url path for the StreamingAssets
  2. An explanation on the similarities and differences between web and mobile for saving and loading JSON files from the StreamingAssets folder

I have seen other questions on here but none that answered concisely about web which helped to understand the proper steps.

WebRequest 407 errors,Web Requests behind a proxy

$
0
0
Hi, We are currently releasing our software to schools however they are unable to log in to our backend system in the app due to their proxy servers needing to authenticate our traffic. It seems it cannot be done using UnityWebRequest. All URLs used by the app are white listed at the school we are testing with. Exceptions are not a good option as most schools will be reluctant to add them. We have tried using other methods such as HTTPWebRequest, adding DefaultCredentials to try authenticate yet we still get 407 errors. Has anyone for any experience with doing Web Requests behind systems that require authentication?

Empty Error DownloadHandler

$
0
0
I am having a problem with a blank / empty error showing up in console. This error does not break the code (It keeps running after the error is displayed), and a try catch does not pickup the error. var clip = DownloadHandlerAudioClip.GetContent(webRequest); Above you can find the line of code which gets highlighted when I double click the error. I suppose it is something related to the DownloadHandler. Since I do not have a clear view on what is goign wrong and it doesn't have a negative effect on my program (Yet), it is rather annoying seeing this in my console. Is this known? (Tried googling, did not give any clear results) I think its a bug in someway, should I report this?

HttpWebRequest doesn't work with Hololens

$
0
0
Hey guys, I'm trying to stream CCTV live video to Hololens, it works fine in Unity Editor but failed in Hololens with an exception of "connect failure TLS support not available". I know UnityWebRequest works better for Hololens but I have to use the HttpWebRequestin this case because of the credentials. Is it because Hololens doesn't support HttpWebRequest? I'm using unity 2018.1.9f2. My code: public void GetVideo() { texture = new Texture2D(2, 2); HttpWebRequest www = (HttpWebRequest)WebRequest.Create(sourceURL); www.Credentials = new NetworkCredential("Username", "password"); ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return true; }); debugText.text += "\ngetting certification"; try { HttpWebResponse resp = (HttpWebResponse)www.GetResponse(); stream = resp.GetResponseStream(); } catch(Exception ex) { debugText.text += "\n"+ex.Message.ToString(); } StartCoroutine(GetFrame()); } IEnumerator GetFrame() { Byte[] JpegData = new Byte[65536]; while (stream != null) { if(streamOnce == false) { streamOnce = true; } int bytesToRead = FindLength(stream); print(bytesToRead); if (bytesToRead == -1) { print("End of stream"); yield break; } int leftToRead = bytesToRead; while (leftToRead > 0) { leftToRead -= stream.Read(JpegData, bytesToRead - leftToRead, leftToRead); yield return null; } MemoryStream ms = new MemoryStream(JpegData, 0, bytesToRead, false, true); texture.LoadImage(ms.GetBuffer()); frame.material.mainTexture = texture; stream.ReadByte(); // CR after bytes stream.ReadByte(); // LF after bytes } } int FindLength(Stream stream) { int b; string line = ""; int result = -1; bool atEOL = false; while ((b = stream.ReadByte()) != -1) { if (b == 10) continue; // ignore LF char if (b == 13) { // CR if (atEOL) { // two blank lines means end of header stream.ReadByte(); // eat last LF return result; } if (line.StartsWith("Content-Length:")) { result = Convert.ToInt32(line.Substring("Content-Length:".Length).Trim()); } else { line = ""; } atEOL = true; } else { atEOL = false; line += (char)b; } } return -1; }

UnityEngine.WWW' has been forwarded to an assembly that is not referenced

$
0
0
The type `UnityEngine.WWW' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `UnityEngine.UnityWebRequestWWWModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' ArgumentException: The Assembly UnityEngine.UnityWebRequestWWWModule is referenced by UnityEngine Error occurs in Unity 2017.4.1 and its blocking from generating the apk file.

Usage of DownloadHandlerAudioClip.streamAudio

$
0
0
Hi all, I am trying to start playing an AudioClip before it has been completely download as hinted at in the documentation for [DownloadHandlerAudioClip.streamAudio][1]. I have written this sample code to illustrate the use I would expect to work: private IEnumerator StartAudioStream() { // Prepare stream string url = "www.brainybetty.com/FacebookFans/Feb112010/ChillingMusic.wav"; DownloadHandlerAudioClip downloadHandler = new DownloadHandlerAudioClip(string.Empty, AudioType.WAV); downloadHandler.streamAudio = true; UnityWebRequest request = new UnityWebRequest(url, "GET", downloadHandler, null); // Start stream UnityWebRequestAsyncOperation token = request.SendWebRequest(); AudioClip audioClip = null; while (audioClip == null) // Ensure audio header completed { try { audioClip = DownloadHandlerAudioClip.GetContent(request); } catch (Exception) { } Debug.LogFormat("Waiting for AudioClip: bytes={0}", request.downloadedBytes); // The complete file is 4834942 bytes yield return 1f; } // Play AudioClip source.clip = audioClip; source.Play(); yield return 0; } Thank you in advance for your time. [1]: https://docs.unity3d.com/ScriptReference/Networking.DownloadHandlerAudioClip-streamAudio.html

Establish a constant connection to a web server

$
0
0
I'm trying to create a connection between a unity game and an web server. Essentially there's 3 parts to the project I'm working on, the main game, a mobile app, and the web server. The Mobile app is able to send a request to the web server and update a value, which is stored in a database. I then need some way for the web server to tell the main game what has happened. Currently I'm having the main game send a web request to the server as well, and then reading the response, but I feel like there's a better way to go about this. Is there any way for the main game to send a single request to the web server, which will establish a connection where the server can respond whenever the mobile app has sent a request.

not working properties DefaultCredentials, DefaultNetworkCredentials class CredentialsCache

$
0
0
How to get the credentials of the connected user at the moment? Binding to the service through application properties DefaultCredentials, DefaultNetworkCredentials, class CredentialsCache always empty The useDefaultCredentailsCache properties of the WebRequest class also do not work. OS: Windows Server: IIS 7.5

java.io.EOFException error

$
0
0
I am facing this problem since long. this happens when I am sending a post request using UnityWebRequest.Post. I also have set chunkedTransfer = false; now every alternate use of yield return www.SendWebRequest() gives me java.io.EOFException. please note that this problem is arising on an android tablet. this works well on my laptop. I tried both built system Gradle and internal. the internet is set to be required. please suggest me any solution.

MultipartFormDataSection not working - Error: 403

$
0
0
This project goal is uploading user image to server so I am trying to test my api with ***UnityWebRequest*** and ***MultipartFormDataSection***.

And I found out I am not able to pass values with ***MultipartFormDataSection*** but ***WWWForm*** is successful to pass values.

**This is my Multipart Code:** List formData = new List (); formData.Add (new MultipartFormDataSection ("fileName", "i_am_fileName.png")); formData.Add (new MultipartFormDataSection ("fileName2", "i_am_fileName.png2")); UnityWebRequest wwwGetURL = UnityWebRequest.Post ("http://www.{myserver}.com/projects/BoLe/api/saveimage.php", formData); wwwGetURL.chunkedTransfer = false; yield return wwwGetURL.Send (); Debug.Log (wwwGetURL.downloadHandler.text); **The Result is** : 403 Forbidden

Forbidden

You don't have permission to access /projects/BoLe/api/saveimage.php on this server.
---------- **This is my WWWForm Code** WWWForm formData = new WWWForm (); formData.AddField ("fileName", "i_am_fileName.png"); formData.AddField ("fileName2", "i_am_fileName.png2"); UnityWebRequest wwwGetURL = UnityWebRequest.Post ("http://www.{myserver}.com/projects/BoLe/api/saveimage.php", formData); wwwGetURL.chunkedTransfer = false; yield return wwwGetURL.Send (); Debug.Log (wwwGetURL.downloadHandler.text); ***The Result is :*** {"return_code": "0","data_content": {"img_url":""},"return_msg": "No File"} Which mean the request was processed successfully, and return proper message. ---------- I was wondering why ***MultipartFormDataSection*** is not working with Error: 403.


UnityWebRequestMultimedia dosent load local file MacOS

$
0
0
I use UnityWebRequestMultimedia to load files from localDrive on this piece of code. But, on MacOS he tries to Load at localhost. How can i change this? ![alt text][1] ![alt text][2] Song.Audio audio = new Song.Audio(); FileInfo guitarFileInfo = new FileInfo(song.fileInfo.Directory.FullName + "/guitar.ogg"); if (guitarFileInfo.Exists) { using (UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip(guitarFileInfo.FullName, AudioType.OGGVORBIS)) { yield return uwr.SendWebRequest(); if (uwr.isNetworkError || uwr.isHttpError) { Debug.LogError(uwr.error); yield break; } yield return null; audio.guitar = DownloadHandlerAudioClip.GetContent(uwr); } } [1]: /storage/temp/130784-captura-de-tela-2019-01-08-as-215204.png [2]: /storage/temp/130783-captura-de-tela-2019-01-08-as-215232.png

WebGL CORS error when trying to get text from a URL. Even when CORS is set?

$
0
0
I'm trying to load high scores for my game from this URL: https://dirtylime.com/games/highscores/display.php?game=space_runner

Since uploading the WebGL build to a seperate domain it's failing to get the URL. I'm getting this Cross-Origin Resource Sharing error in the browser console:

Access to XMLHttpRequest at 'https://dirtylime.com/games/highscores/display.php?game=space_runner' from origin 'https://uploads.ungrounded.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

But my webpage does have a Access-Control-Allow-Origin header set to * so I can't figure out what could be stopping it.

I can confirm that the header is set using an online testing tool. http://tools.seobook.com/server-header-checker/?url=https%3A%2F%2Fdirtylime.com%2Fgames%2Fhighscores%2Fdisplay.php%3Fgame%3Dspace_runner&useragent=8&protocol=11

Here's the C# code I'm using to try load the URL:

UnityWebRequest hs_get = UnityWebRequest.Get(highscoreURL); yield return hs_get.SendWebRequest(); if (hs_get.isHttpError) { scoresText.text = "There was an error getting the highscores:\nPlease try again."; } else { scoresText.text = hs_get.downloadHandler.text; }

Unity 2018 hits don't show in Google Analytics

$
0
0
Since moving to Unity 2017/2018 from Unity 5.6, suddenly analytic data to Google Analytics does not arrive anymore. The server says 200 (ok) and there are no errors whatsoever. If the same url is used in the browser, the hit shows as expected. When comparing the traffic between a working 5.6 version and a non-working 2018 version, there is almost no difference: GET https://www.google-analytics.com/collect?v=1&ul=en&sr=1>> blablathequery HTTP/1.1 Host: www.google-analytics.com Accept: */* Accept-Encoding: identity User-Agent: UnityPlayer/>> 5.6.6f2 (http://unity3d.com) X-Unity-Version: >> 5.6.6f2 vs GET https://www.google-analytics.com/collect?v=1&ul=en&sr=1>> blablatheexactsamequery HTTP/1.1 Host: www.google-analytics.com Accept: */* Accept-Encoding: identity User-Agent: UnityPlayer/>> 2018.2.19f1 (UnityWebRequest/1.0, libcurl/7.52.0-DEV) X-Unity-Version: >> 2018.2.19f1 Content-Type: application/x-www-form-urlencoded So what gives? Okay, I actually already know the answer, but I want to help people with the same issue (including future me). Here it comes:

Download progress is -1 forever.

$
0
0
Hello, I want to download files from my FTP server. The login and password in the code is correct I checked it many times. Also the link to the file is correct I guess. The download code is not my code I found it on the Unity Forum here: https://stackoverflow.com/questions/43411525/download-files-via-ftp-on-android And the code is here: ---------- using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; using System.Net; using System; using System.Text; using System.IO.Compression; public class GameUpdater : MonoBehaviour { public byte[] downloadWithFTP(string ftpUrl, string savePath = "", string userName = "", string password = "") { FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri(ftpUrl)); //request.Proxy = null; request.UsePassive = true; request.UseBinary = true; request.KeepAlive = true; //If username or password is NOT null then use Credential if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password)) { request.Credentials = new NetworkCredential(userName, password); } request.Method = WebRequestMethods.Ftp.DownloadFile; //If savePath is NOT null, we want to save the file to path //If path is null, we just want to return the file as array if (!string.IsNullOrEmpty(savePath)) { downloadAndSave(request.GetResponse(), savePath); return null; } else { return downloadAsbyteArray(request.GetResponse()); } } byte[] downloadAsbyteArray(WebResponse request) { using (Stream input = request.GetResponseStream()) { byte[] buffer = new byte[16 * 1024]; using (MemoryStream ms = new MemoryStream()) { int read; while (input.CanRead && (read = input.Read(buffer, 0, buffer.Length)) > 0) { ms.Write(buffer, 0, read); } return ms.ToArray(); } } } void downloadAndSave(WebResponse request, string savePath) { Stream reader = request.GetResponseStream(); //Create Directory if it does not exist if (!Directory.Exists(Path.GetDirectoryName(savePath))) { Directory.CreateDirectory(Path.GetDirectoryName(savePath)); } FileStream fileStream = new FileStream(savePath, FileMode.Create); int bytesRead = 0; byte[] buffer = new byte[2048]; while (true) { bytesRead = reader.Read(buffer, 0, buffer.Length); if (bytesRead == 0) break; fileStream.Write(buffer, 0, bytesRead); } fileStream.Close(); } } There is no errors in the downloading script above. I use it like that: ---------- string path = Path.Combine(Application.persistentDataPath, "/temp"); path = Path.Combine(path, "testfile.zip"); GameUpdater.GetComponent().downloadWithFTP("ftp://dfpsgamehost@files.000webhost.com/testfile.zip", path, "login", "password");

Send a form to a HTTP server in rails

$
0
0
Hi, i'm trying to use UnityWebRequest to send a form to a Ruby on Rails server, but the error, HTTP/1.1 404 Not Found, keep comming. My code is here: public void Update_GI_Score() { StartCoroutine(Update_GI_Score_FORM()); } IEnumerator Update_GI_Score_FORM() { WWWForm form = new WWWForm(); form.AddField("myField", "myData"); Game game = Singleton.GameInstance; foreach (Score s in game.scores) { form.AddField("name", s.Name); form.AddField("value", s.rate.ToString()); } var url = RequestController.Instance.baseURL + "atualiza_score"; UnityWebRequest www = UnityWebRequest.Post(url, form); yield return www.SendWebRequest(); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { Debug.Log("Form upload complete!"); } } In the rails routes i got: post 'atualiza_score', controller: 'integracao_games', action: :atualiza_score so how can i get the form correctly, i need to save the field into a database thanks.
Viewing all 387 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>