Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
avatar image
1
Question by totallymorten · Jun 10, 2019 at 01:48 PM · unity 5httpandroid-sdkhttpwebrequest

UnityWebRequest returning responseCode 0 and isNetworkError == true for Unity 2019

From my Android app I execute a http PUT request with JSON:


 String fullUrl = "http://myserver.com/mycontroller/loginJson.json";
 
 UnityWebRequest www = UnityWebRequest.Put(fullUrl,json);
 
 www.SetRequestHeader("Content-Type", "application/json");
 
 yield return www.SendWebRequest();


This code works fine when building with Unity 2018.4.1f1. But if I build with Unity 2019.1.6f1 I get:


 www.error : "Unknown"
 www.responseCode: 0
 www.isNetworkError: true
 www.isHttpError: false
 www.downloadHandler.text : ""


When I run this code directly in unity, it works fine, and I have no problems communicating with the server. Only building to Android in Unity 2019.1 doesn't work. I also tried the new 2019.3.0a5, and there the Android version also works. This is quite a mystery.

Anyone have any idea what's going on?


=== UPDATE 2019-06-22 ===
I've found that it's probably not related to Unity, but to the Android SDK. If I build with API level 27 (8.1), it works fine, but with API level 29 (9.0), I get the "Unknown Error". I'll continue to look into this.
=======================

Comment
Add comment · Show 2
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 Bunny83 · Jun 22, 2019 at 12:48 PM 0
Share

Your "update date" is one month into the future ^^. Note that important parts are missing in your question. Especially which protocol you're using. $$anonymous$$any platforms recommend / restrict web traffic to SSL encrypted connections and refuse unsecure connections such as plain text http. Even when using https, self-signed certificates are not considered secure and may also cause the connection to be refused.


Since this informations is hidden in your "fullUrl" we can't be sure if that's the issue.

avatar image totallymorten Bunny83 · Jun 22, 2019 at 02:05 PM 0
Share

@Bunny83 Thanks for your reply - update date corrected. I've added an url similar to the one I use in the app. I use http protocol - this is only a prototype app. The server is running a Ruby On Rails backend on heroku. Note that the EXACT same application works when built to Android API level 27, but fails with level 28. No modifications. I wonder if it's some new security settings / requirements in the new Android API. $$anonymous$$aybe my app needs to request more access to network or something.....

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Bunny83 · Jun 22, 2019 at 02:43 PM

It's probably a security setting. Though as I said many companies try to push https as the standard in the web Many still allow http but show a warning.


Have you actually tried looking at the log? (logcat)


ps: I just had a look at the update notes

Network TLS enabled by default

If your app needs to enable cleartext for specific domains, you must explicitly set cleartextTrafficPermitted to true for those domains in your app's Network Security Configuration.

So you might need something like:

 <network-security-config>
     <domain-config cleartextTrafficPermitted="true">
         <domain includeSubdomains="true">your.domain.name.com</domain>
     </domain-config>
 </network-security-config>


Though another option is to just get a free Lets Encrypt certificate and use https. Note that Lets Encrypt certificates need to be refreshed every 3 month, however this can be automated on the server. I've done it on my raspberry pi.

Comment
Add comment · Show 2 · 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 totallymorten · Jun 22, 2019 at 02:55 PM 0
Share

That really sounds like a plausible solution! thanks. I'm gonna look into it tomorrow and post back here! $$anonymous$$uch appreciated!

avatar image totallymorten · Jun 25, 2019 at 11:25 AM 0
Share

@Bunny83 I think definitely you are correct. I've been reading up on the changes in Android 9. I'm thinking either to go for your suggestion (allow http) or try to allow un-signed certificates (until I get a proper one) by using this strategy: https://answers.unity.com/questions/1482409/how-to-accept-self-signed-certificate.html

Would you like to post your answer as a "real" answer, so I can mark it "correct"?

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

202 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 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

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

UriFormatException: Invalid URI: Invalid port number for VirtualBox server using IPv6 Address 1 Answer

UnityWebRequest object downloadhandler.text not returning same/all data compared to browser 0 Answers

can we send data to GET api?,can we send data to get type api ? 0 Answers

Unable to call external API (IBM Watson) via HTTP request? 1 Answer


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