- Home /
Getting Fatal Error 2030 using WWW in Flash
I've stumbled upon an error I just can't understand. When doing a WWW to a certain php I get:
Fatal Error : Error: Error #2030: End of file was encountered.
at flash.net::URLStream/readBytes()
at com.unity::UnityNative$/Ext_UrlStream_CopyBytes()
at com.unity::UnityNative$/_ZN8WWWFlash12DoneCallbackEii()
at com.unity::UnityNative$/WWWFlashCallbackSize()
at com.unity::URLStreamHandler/onURLLoaderComplete()
So I stripped the php down to just returning the string "0" and the WWW function to just:
WWW www = new WWW("http://195.178.163.254/summergames/test.php");
yield return www;
print(www.text);
But I'm still getting the same error.
Now to the real weird part. I'm not getting any error when posting to some of our other php's.
Btw, the error only shows when exporting to Flash. Works just fine in the editor.
Loading test.php with URLLoader or URLStream in Flash does not generate the error either.
Any ideas?
Answer by catburton · Jun 19, 2012 at 05:02 PM
Thanks for reporting this. I've raised a bug report for this issue.
In the meantime, you can work around this issue by doing your web request in pure AS3 inside your Unity project:
Create an AS3 class in your project which has a function to perform the web request and store the response. Put this class in a folder called ActionScript.
Now create a matching class in C# and add the [NotConverted] and [NotRenamed] attributes so that this class will not be converted to AS3 at runtime.
In your project, assuming the C#/AS3 classes have the same API, you should be able to create a new instance of this class and use its web request function.
I've hacked together a very quick example (attached) which works for your test.php service. Hopefully you can use this to fix your project.
I need help with these example:
in C#: [NotRenamed] public static string response;
in AS: public static var response : String;
but i need to pass an array to AS:
in C#: public string[] variables;
in AS: public var variables:String[];
==> Unity debug error WWWCaller.as: Syntax error: expecting semicolon before leftbracket.
==> how to fixed?
Answer by munnaz · Aug 15, 2012 at 07:10 AM
awesome. thanks so much Cat. just having problems when i use the class in that i want to modify the WWWCaller class in actionscript but unity is giving me compile time errors saying
error CS1061: Type WWWCaller' does not contain a definition for
DoUserRequest' and no extension method DoUserRequest' of type
WWWCaller' could be found (are you missing a using directive or an assembly reference?)
either that or pass a url through in DoWebRequest("http://url").
How do i go about compiling the new WWWCaller class in actionscript within the Unity stuff or should it happen automatically.
thanks for any help
Answer by munnaz · Aug 15, 2012 at 07:10 AM
ah figured it out
[NotRenamedAttribute] public void DoWebRequest() { //Do nothing in this case. }
needed to put a function within WWWCaller.cs
Answer by manuelv · Sep 19, 2012 at 10:34 AM
Also Thanks so much too.
Great example WWW
useful because flash unity WWW for WWW.text return null
with your function, it's work
Answer by Ghisallo · Oct 09, 2012 at 04:07 PM
For the benefit of anyone that is wondering how to pass an url parameter to the DoWebRequest in the Action Script linked above (as I was), you can make the following changes.
var address:String;
public function DoWebRequest(address) : void
{
request = new URLRequest();
request.url = address;
In TestWWW.cs:
#else
WWWCaller wwwCaller = new WWWCaller();
wwwCaller.DoWebRequest("http://whatever.etc");
And most importantly, in WWWCaller.cs:
public void DoWebRequest(string address)
Without the last change, the build will not compile because it seems the whole point of WWWCaller.cs is to act as a placeholder for WWWCaller.as, which Unity will not check for errors. However, if Unity finds errors in WWWCaller.cs, it will not compile. This puzzled me for the longest time, but now it makes complete sense.
Your answer
Follow this Question
Related Questions
Unity Fatal Error guid is uninitialized 1 Answer
WWW Flash: No gzip support? 0 Answers
"Absolute URI is too short" woe 1 Answer
GetThreadContext failed during runtime (not in editor) 0 Answers
Fatal Error! Out of memory. 2 Answers