Quickstart-unity: Unity Editor (2018.3) crashes using Database v5.4.4

Created on 9 Feb 2019  路  20Comments  路  Source: firebase/quickstart-unity

Unity editor version: 2018.3.5f1
Firebase Unity SDK version: 5.4.4
Additional SDKs you are using (Facebook, AdMob, etc.): empty project with Firebase only
Platform you are using the Unity editor on (Mac, Windows, or Linux): Mac
Platform you are targeting (iOS, Android, and/or desktop): iOS

Please describe the issue here:

The 1st problem I met implementing Database is that WebSocket errors appear after Database initialisation. Here is an issue described and solution I used to make it run in Editor:
https://stackoverflow.com/questions/50651865/unityfirebase-databaseerror-websocket-ws-0-could-not-connect

That helped to solve WebSocket issue, but another has appeared. It's very similar to that one - https://github.com/firebase/quickstart-unity/issues/200
Very easy to replicate - set database url, call database update request, something like
FirebaseDatabase.DefaultInstance.RootReference.Child(subDatabase).Child(key).SetRawJsonValueAsync(jsonString);
Press Play and call the method. Stop, and Play again - Editor crashes or freezes.

That problem don't allow to use Firebase at all... Wasted so much time trying to find the solution but nothing. How you "Firebase dev team" even can release such SDK's?! Shame

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?
Yes

question

Most helpful comment

I have this problem with mac os with unity 2019.1.10 and Firebase 6.3.0 In play mode everything is ok, but as soon as I stop, Unity crashes. No other errors.

All 20 comments

Nice description of what I am also experiencing.

:(

This should be fixed soon when the new desktop version of Firebase Database (based on the C++ SDK) becomes available.

Having the same issue on our artist's mac. :/ Any idea when the new desktop code will be released?

@novavision to be clear here, the "workaround" described in https://stackoverflow.com/questions/50651865/unityfirebase-databaseerror-websocket-ws-0-could-not-connect is not the well lit path. As @jonsimantov mentioned, we do not support the C++ implementation of the RT DB (which is used when you apply the workaround) in Unity at the moment. This will be coming soon.

Instead you should check your network configuration to see what is blocking the websocket connection from the C# implementation (currently the default one before the workaround is applied) and use that instead.

Well, since the connection works fine in c# on the windows side, "Instead you should check your network configuration to see what is blocking the websocket connection from the C# implementation (currently the default one before the workaround is applied) and use that instead." Is a pretty insulting comment

I too have this issue.
I can either aply the "fix" described in the link and have Unity crashing constantly
or have the no connection error

Here's hoping to a third option.

It would be cool if you could explain how i could do the websocket thing - I just want this stuff to work

I also ran into this issue. It would be great if we can think of a temporary fix that would not crash the engine every other session.

fwiw, I picked up a mac mini to see if I could help solve the issue for my artist and ended up not hitting it. I am using Unity 2018.3.6f1 and Firebase Unity SDK 5.5.0, targetting iOS. I tried Unity 2018.3.5f1 thinking maybe .6 added some fix, but same result - No websocket issues.

The artist still has them on her Mac laptop, same code and version of Unity and Firebase, so evidently, there is some other variable at play here.

Firstly, @fingerfunkNIK in particular I didn't mean to insult anyone here. I'm just making it clear that we have a RT DB C# implementation that is enabled by default and should not be hacked to use the desktop C++ implementation (we have C#-->C++ proxy DLLs that are used on mobile) since it's known to not work.

Now perhaps I can explain a bit more about what is going on then folks can ask their IT admins about this. Connections to the Realtime Database (RT DB) - when doing anything that involves the full protocol - requires Websockets secure (specifically the wss:// scheme). It's possible to connect to the RT DB using REST but many features are not supported. The RT DB C# implementation - similar to Android & iOS - uses Websockets for connections. This is typically fine as most modern proxies and load balancers don't modify data flowing between the Websockets client and the RT DB server. However, in some cases a HTTP proxy or L7 load balancer will break the websocket connection, for more information see this article by Peter Lubber, who just so happens to now be a fellow Googler and this Wikipedia article.

The reason why the C++ RT DB implementation when applying the hack mentioned in this stackoverflow response "kinda" works is that it uses a REST connection to the RT DB and is pretty seriously hobbled by this. We put together a client that only uses a REST connection to get something, anything for C++ developers to use when debugging on desktop. We've been working on switching the RT DB C++ implementation to use websockets throughout similar to our mobile implementations and should have something ready soon. So we'll likely consistently see connection issues due to badly configured software / hardware everywhere.

Now there's the background, but how to solve the issue?
After a quick hunt around the web (thanks Google) I discovered that many web applications run into similar issues including Slack. Slack has a really nice debugging guide here that can be applied to the RT DB. The only difference is that the hosts that will need to be whitelisted are *.firebaseio.com.

Folks, please let us know whether this resolves your issue.

Hey - thanks for your reply.
I looked at the slack guide, but I'm still confused about how to solve this.
Is it my computer or my router that needs to be set up in a specific way? How do I do it?
Sorry for my networking ignorance.

@asger60 you need to check that the software on your computer isn't blocking websocket connections (see network environment), then if you're on a corporate network I recommend asking your IT folks to whitelist connections to *.firebaseio.com (i.e see slack's description)

I stopped my add blocking software (didn't have anything else from the list)
Did this https://support.apple.com/en-za/guide/mac-help/enter-proxy-server-settings-on-mac-mchlp2591/mac (to add *firebase.com)

Also - I tried making completely free Unity (2018.3.6) project with nothing but firebase

And I shut down a bunch of more or less random programs on my computer (safari, spark, unity hub).

But it's still not working.

2/28/2019 8:46:10 PM [Error] WebSocket: ws_11 - could not connect
System.Net.Sockets.SocketException (0x80004005): No route to host

I'm just on my home network btw.

Seems logical that the general network configuration has little to do with this issue. In my case I can get my old clunky windows 10 pc to behave as expected, and my mac just wont, both sitting behind the same router. After exhausting the different local network security settings I found on my mac, I finally found a workaround that seems to be productive: In the Unity Editor settings: set "scripting runtime version" to 3.5 (deprecated) "scripting backend" to Mono and "API compatibility level" to .Net 2.0. This way I can connect to the db more than once.

yep, I can confirm this is working for me as well - thanks fingerFunkNIK
It would be cool to not have to revet to a depricated scripting version to get the db to work.

Why is this closed?
Unity crashes here also
With settings: Firebase.Database
in Mono: Editor-Enabled
in Plugins: Editor-Disabled
Result- Crash when running.

Second scenario-
in Mono: Editor-Disabled
in Plugins: Editor-Enabled
Catch error when "reference = FirebaseDatabase.DefaultInstance.RootReference"

I use .net 4 scripting and can't revert because I need it for my script.

Edit: I reverted back to Firebase 5.4.4 (from 5.5.0), the problem is gone. Please report it as a bug. I won't upgrade til the problem is fixed.

@shlighter reported bug was with a hacked version of the SDK which is unsupported. If you have run into another issue with our latest SDK https://firebase.google.com/support/release-notes/cpp-relnotes#5.6.1 then please share the reproduction with our sample application with us on a new issue and we'll take a look.

I have this problem with mac os with unity 2019.1.10 and Firebase 6.3.0 In play mode everything is ok, but as soon as I stop, Unity crashes. No other errors.

I am currently facing the same problem with
unity 2019.1.12 and
firebase_unity_sdk_6.3.0.
whenever i try to run the method that writes to firebase, Unity just offs

Same, I'm using Unity 2018.4.4 and target Android. When I run the editor without internet twice it crashes and when I build it to either iOS or Android it doesn't even run the .GetFileAsync() to see if I have an internet connection so its hard to handle a network error when it can't see if it's canceled or faulted.

Was this page helpful?
0 / 5 - 0 ratings