System.Net.Sockets.SocketsException: Network is unreachable
I must have broken something. I haven’t done much with this project in a while (adding a scrollview to a scene) and tried running it in the editor today but this error occurred. It’s using the Firebase plugin.
Current setup:
Elementary OS 0.4.1 Loki - Built on “Ubuntu 16.04.3 LTS”
Linux 4.4.0-109-generic
Unity 2017.2.0b2
Things I tried to fix it:
Try on a different version of Unity 2017.3.0b1 by setting up a brand new project, importing Firebase Analytics, Database, Messaging, and Auth.
Typed “System.Net.Sockets.Socket” which all autocompleted well but “.Connect” didn’t show.
EDIT: Tried on a different computer using the same OS and Unity and the same thing happened.
1/24/2018 9:27:07 PM [Error] WebSocket: ws_0 - could not connect
System.Net.Sockets.SocketException: Network is unreachable
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) [0x00000] in :0
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in :0
at System.Net.Sockets.TcpClient.Connect (System.Net.IPEndPoint remote_end_point) [0x00000] in :0
at Firebase.Database.Internal.TubeSock.WebSocket.CreateSocket () [0x00000] in :0
UnityEngine.Debug:LogError(Object)
Firebase.Platform.FirebaseLogger:LogMessage(PlatformLogLevel, String)
Firebase.Unity.UnityLoggingService:LogMessage(PlatformLogLevel, String)
Firebase.Database.Internal.Logging.DefaultLogger:Error(String, String)
Firebase.Database.Internal.Logging.DefaultLogger:OnLogMessage(Level, String, String, Int64)
Firebase.Database.Internal.Logging.LogWrapper:Error(String, Exception)
Firebase.Database.Internal.TubeSock.WebSocket:LogError(String, Exception)
Firebase.Database.Internal.TubeSock.WebSocket:CreateSocket()
Firebase.Database.Internal.TubeSock.WebSocket:RunReader()
Firebase.Database.Internal.TubeSock.Runnable101:Run()
Google.Sharpen.Thread:InternalRun()
I found the following in Editor.Log occurring just before the socket exception.
Fallback handler could not load library /home/benjamin/Unity-2017.3.0p2/Editor/Data/Mono/lib/lib/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.so
Fallback handler could not load library /home/benjamin/Unity-2017.3.0p2/Editor/Data/Mono/lib/.//System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
Fallback handler could not load library /home/benjamin/Unity-2017.3.0p2/Editor/Data/Mono/lib/./lib/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.so
Fallback handler could not load library /home/benjamin/Unity-2017.3.0p2/Editor/Data/Mono/lib/lib/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
Fallback handler could not load library /home/benjamin/Unity-2017.3.0p2/Editor/Data/Mono/lib/lib/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.so
Fallback handler could not load library /home/benjamin/Unity-2017.3.0p2/Editor/Data/Mono/lib/./lib/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
Fallback handler could not load library /home/benjamin/Unity-2017.3.0p2/Editor/Data/Mono/lib/./lib/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.so
Fallback handler could not load library /home/benjamin/Unity-2017.3.0p2/Editor/Data/Mono/lib/lib/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
Unfortunately I have not. I stopped working on the project for a couple weeks, then opened it up and it worked again.
I wish I knew all the things I tried but I did spend two weeks prior to stopping work on it trying to fix it. I do think I got it working on my mac by updating to the latest Unity and updating Firebase.
According to my stackoverflow post I got it working by changing the .Net version in project settings “…switching to 4.6 in my 2017.2.0b2 project made it not open but switching to 4.6 in 2017.3.0b1 worked.” Though, this might have caused other errors.
I ran into the same issue trying to run on iOS and spent two days trying to find the issue. Following the unity/firebase docs word for word I kept running into this. What finally worked for me was changing my .NET version from 3.5 to 4.x under Player Settings → Scripting Runtime Version.
The solution to this is to go into the Firebase folder then plugins and finally mono. Then click on the Firebase.Database file, on the import settings make sure it doesn’t include any platforms and click apply. Then go back out of the mono folder and in the plugins folder you should currently be in , click on the Firebase.Database file and on the import settings make sure it includes all platforms and click apply. This is not my fix I would cite if I remembered who found it.