Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by Ashiash · Jan 30, 2018 at 08:29 AM · httpplatformswww classhttpwebrequesthttps

WWW class and UnityWebRequest no longer working in Unity 2017.3.0

Hi guys,

I've been tasked with porting one of our apps from Unity 5.6.0 to Unity 2017.3.0. This app runs on the following platforms:

  • Windows Standalone

  • Windows Universal Store App

  • iOS

  • and Android

So far, the Windows Standalone version works fine. The problems start with the Windows Univeral Store App version: With this platform I don't seem to be able to make any kind of http or https request. Previously when using Unity 5.6.0 we used the www class to make these requests. Here is a code snippet of the original code:

 if (Application.internetReachability != NetworkReachability.NotReachable)
         {
             // Construct header and append the encrypted XML string to the headers byte array. 
             byte[] aRequest = AppendHeader(strXMLRequest);
             WWW cWWW = new WWW(m_strURL, aRequest);
 
             while (!cWWW.isDone)
                      yield return null;
 
             try
             {
                   m_strXMLResponse = cWWW.text;
              }
              catch
              {
                   Debug.LogError("Download error!");
                   m_strXMLResponse = "";
               }
             }

This code no longer works under Windows Universal platform. cWWW.text is always empty. Now I realize that the WWW class is deprecated, so I decided to rewrite the code so it uses the UnityWebRequest class.

Here is another short code snippet:

 UnityWebRequest uwr = UnityWebRequest.Post(m_strURL,"");
  yield return uwr.SendWebRequest();
 
 if(uwr.isNetworkError)
 {
    Debug.Log("Error While sending: " + uwr.error);
  }
 else
 {
    Debug.Log("Received: " + uwr.downloadHandler.text);
 }

However with this code uwr.isNetworkError is always true and uwr.error is always set to: "Generic/unknown http error." This is the case for any kind of http or https url. So at the moment ist seems I can not perform any kind of http or https request using unity classes in Unity version 2017.3.0. I downloaded Unity 5.6.0 again just to make sure it wasn't something to do with my computer or maybe some new settings that the sys admins made to the company firewall. - the code worked fine. Going back in Unity versions I could see that the code works up unitl Unity version 2017.2.1. So it would seem this is some kind of bug or regression within Unity 2017.3.0. I've tried all the patch versions of Unity 2017.3.0 and the 2018 Beta version and the problem persists in all these versions.

Could someone please confirm if this is really an unintended bug and if there is some kind of workaround? If it is a Unity bug I would say this is very critical. Any help or feedback would be greatly appreciated.

Cheers...

Comment
Add comment · Show 8
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dandando · Jan 30, 2018 at 06:14 PM 0
Share

Are you using an http or https URL?

avatar image Ashiash dandando · Jan 31, 2018 at 06:33 AM 0
Share

https. But I've also tried it with a http URL. Our server never receives the request.

avatar image fernforce Ashiash · Feb 03, 2018 at 10:22 AM 0
Share

In my case, my server does receive the request but yield return uwr.SendWebRequest(); never returns

avatar image MaxxRafen · Feb 09, 2018 at 04:45 AM 0
Share

Having this very exact issue as well.

avatar image MaxxRafen MaxxRafen · Feb 09, 2018 at 04:55 AM 0
Share

I tried using wwwForm ins$$anonymous$$d of byte data, but the result is the same. The post itself and the headers send (via WWW), but the data is getting lost in the process.

avatar image fernforce MaxxRafen · Feb 09, 2018 at 05:39 AM 0
Share

Can you get any coroutines to work in that script other than sendwebrequest? such as: StartCoroutine(Test());

public IEnumerator Test() { yield return new WaitForSeconds(1f); Debug.Log("yielded fine."); }

avatar image fernforce · Feb 09, 2018 at 05:53 AM 0
Share

Do you have a server and are able to make requests to it, and what do the logs look like on the server end? does it log a good response?

avatar image Ashiash fernforce · Feb 09, 2018 at 07:14 AM 0
Share

Yes, I have a server. But it's not receiving anything. However I've reverted back to Unity 2017.2.1 and everything works fine again. When Unity 2017.3.1 comes out I'll give it another go.

5 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by FiveFingers · Feb 02, 2018 at 10:14 PM

Yeah...they can't make it right...too many tasks. Switching back to 5.6

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by fernforce · Feb 03, 2018 at 10:18 AM

I couldn't make UnityWebRequest work either so I started using some .net stuff (I guess) to access web stuff...

WebClient client = new WebClient();
Stream data = client.OpenRead(url);
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();

and for binary data:
WebClient client = new WebClient();
Stream data = client.OpenRead(repositoryForTerrains + terrainName + ".raw");
byte[] raw = new BinaryReader(data).ReadBytes(sizeOfTerrainFile);

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fernforce · Feb 03, 2018 at 07:47 PM 0
Share

What I posted here is not acceptable solution so I got unitywebrequest to work by setting the script containing my unitywebrequest code as component to another object. Furthermore, I discovered that coroutines stop and won't continue when you setActive(false) and setActive(true) once again on the object containing the script. Here is reference to someone who answered this particular issue that may solve someone's issue unitywebrequest: https://answers.unity.com/questions/34169/does-deactivating-a-gameobject-automatically-stop.html

avatar image
0

Answer by rafetts · Feb 16, 2018 at 04:07 PM

Did anyone fixes this issue?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by yuyenkan999 · Feb 20, 2019 at 08:01 AM

disable chunkedTransfer, add accept and user-agent header on request, should be work.,disable chunkedTrasnfer, set accept and user-agent on header, should be work

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Keyserjaya99 · Mar 25, 2019 at 06:17 AM

I've fixed it by set "www.chunkedTransfer = true;"

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ashiash · Mar 25, 2019 at 06:50 AM 1
Share

Thank you. But we switched to Unity 2018.x.x a long time ago. The old initial versions of Unity 2017 were just too buggy for our needs.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

131 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

HTTP GET Method in C# Unity 3D - How to target specific text or header 1 Answer

Unity to PHP to XML / Upgrade issues 0 Answers

Login cookies 2 Answers

[ASP.NET] [WEB API] Problem with HttpWebRequest.ContentType 0 Answers

Establish a constant connection to a web server 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges