Firebase Storage upload errors in Unity

1,398 views
Skip to first unread message

Simon Hopkin

unread,
Feb 7, 2017, 5:23:05 PM2/7/17
to Firebase Google Group
Hi,

I'm running Firebase Auth, Database and Storage in Unity.  I'm going through auth without any problems and I'm also using the database without any issues.  However when I try to use Storage I get an error when trying to upload an object when running on Android or iOS devices.  

I see the following error in the logs:

gs://<MYAPPNAME>.appspot.com/images/someimage.png network unavailable, sleeping.

Firebase.Storage.Internal.ExponentialBackoffSender:SendWithExponentialBackoff(NetworkRequest, Boolean)

Firebase.Storage.UploadTask:SendWithRetry(NetworkRequest)

Firebase.Storage.UploadTask:BeginResumableUpload()

Firebase.Storage.UploadTask:Run()

Firebase.Storage.StorageTask`2:<GetRunnable>m__2()

Firebase.Storage.ActionRunnable:Run()

Google.Sharpen.ThreadPoolExecutor:RunPoolThread()

Google.Sharpen.Thread:InternalRun()

 

(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)


Error getting response stream (Write: The authentication or decryption has failed.): SendFailure

Firebase.UnityHttpRequest:EnsureExecuted()

Firebase.UnityHttpRequest:get_ResponseCode()

Firebase.Storage.Network.NetworkRequest:ParseResponse(FirebaseHttpRequest)

Firebase.Storage.Network.NetworkRequest:PerformRequestStart(String)

Firebase.Storage.Network.NetworkRequest:PerformRequest(String)

Firebase.Storage.Internal.ExponentialBackoffSender:SendWithExponentialBackoff(NetworkRequest, Boolean)

Firebase.Storage.UploadTask:SendWithRetry(NetworkRequest)

Firebase.Storage.UploadTask:BeginResumableUpload()

Firebase.Storage.UploadTask:Run()

Firebase.Storage.StorageTask`2:<GetRunnable>m__2()

Firebase.Storage.ActionRunnable:Run()

Google.Sharpen.ThreadPoolExecutor:RunPoolThread()

Google.Sharpen.Thread:InternalRun()


I have set the storage rules as follows so it's not dependent on authentication:

service firebase.storage {
  match /b/<MYAPPID>.appspot.com/o {
      match /{allPaths=**} {
         allow read;
         allow write;
      }
  }
}

It has worked in the past, but since then I have upgraded to Firebase Unity release 1.1.1 and now 1.1.2.  I only just noticed its no longer working.


Any advice would greatly received.

Benjamin Wulfe

unread,
Feb 9, 2017, 2:39:02 PM2/9/17
to Firebase Google Group
Hi Simon.

I'm sorry you are having these problems.  Can I ask you to try two things?

1. Try with an open storage bucket.  Turn on public access as described here.  And do not log in with any auth account.  In fact, erase all your app data so there is no cached logged in user  (you should see a log warning telling you the request is unauthenticated which in this case is *ok*)

2. Turn on logging with the latest release.  There was a bug in a previous release that hid some error messages -- including permission denied or not found errors.  Especially if #1 works, try doing a clean install of the latest SDK with logging set to *Debug* -- NOT Verbose.  Verbose will turn on an extra logging feature that could be affecting you.

Regards
-Ben

Simon Hopkin

unread,
Feb 12, 2017, 7:03:17 PM2/12/17
to Firebase Google Group
Hi Ben,

Thanks for getting back to me.

So I tried #1 and I get exactly the same when running on Android or iOS.  If I run within Unity I get a warning "no auth token for request" as you suggested but the file was uploaded successfully.

Regarding #2 I'm not sure what you mean by install the SDK with logging set to Debug?  I just import the unity packages into my unity project.  I'm not aware of any logging setting during the install.  Please could you clarify this point.

Thanks for your help.

Simon Hopkin

unread,
Feb 12, 2017, 7:03:17 PM2/12/17
to Firebase Google Group
Looks like its some kind of certificate trust issue?  I found this thread and added the referenced code and now the uploads work:


Any idea why I may need to do this now and not before when I first started using firebase storage a few weeks ago?

Benjamin Wulfe

unread,
Feb 13, 2017, 1:55:44 PM2/13/17
to Firebase Google Group
You can turn on logging by setting the property:

FirebaseStorage.DefaultInstance.LogLevel = LogLevel.Debug;

That's all I mean. There may be an issue by setting this to LogLevel.Verbose which incidentally could be fixed by setting the callback you used to fix the issue.
Note that I do not recommend setting that callback because it's very easy to get validation wrong and there are also issues with the callback that can cause errors.

The fact that the realtime database is working means that ssl root certificates are being installed. So my best guess here is that either you are setting Verbose logging
somewhere *or* there is an issue with byte stripping (please try with byte stripping disabled). Also, have you tried the storage quickstart
(https://github.com/firebase/quickstart-unity)? I'd try that and add an initial login with email/passwd to ensure that the issue isn't anything else in your sample project.

Kashif Tasneem

unread,
Feb 24, 2017, 11:54:33 AM2/24/17
to Firebase Google Group
Hello. I am facing the same issue, its working fine on Unity Editor with public read and write access but is not working on iOS device. How did you fix it? Thanks.

Benjamin Wulfe

unread,
Feb 28, 2017, 5:47:36 PM2/28/17
to Firebase Google Group
Please try downloading the latest version of the SDK here:


There was a change to the storage SDK that broke it when using the full SDK (it only worked with .Net 2.0 Subset with iOS).
This has been fixed with the latest version.

-Ben
Reply all
Reply to author
Forward
0 new messages