Hi, I'am trying to connect my app with database on server. I copied : MySql.Data.dll, System.Data.dll, System.Drawing and I18N dlls to Plugin folder. In Editor everithing is ok, connection string is ok, and stored procedures from db works properly, but after build app via web gl there is an error when I trying to create istane of MySqlConnection. Code (CSharp): public class Db: MonoBehaviour { private const string connectionString = "Server=name; Database=xxx; UserId=xxx; Password=xxx"; // connection object MySqlConnection con = null; void Awake() { try { con = new MySqlConnection(connectionString); con.Open(); Debug.Log("Connection State: " + con.State); } catch (Exception ex) { Debug.Log(ex.ToString()); } } } I was trying to use Unity 2017, 5.50b11, 5.42f2 Spoiler: An error occured running the Unity content on this page. An error occured running the Unity content on this page. See your browser's JavaScript console for more info. The error was: uncaught exception: abort(111) at jsStackTrace@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1056:12 stackTrace@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1070:21 abort@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2455486:43 nullFunc_iiii@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:15480:2 b111@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2438188:1 __ZN16VirtFuncInvoker1IP24ObjectU5BU5D_t3614634134bE6InvokeEjPvb [Invoke? VirtFuncInvoker1<bool*>(unsigned int, void*, bool)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2227555:1 _MySqlConnectionStringBuilder_AddKeywordFromProperty_m3073566240@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1032859:1 _MySqlConnectionStringBuilder_Initialize_m3878957688@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1670492:1 _MySqlConnectionStringBuilder__cctor_m1042839471@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1962630:1 __Z31RuntimeInvoker_Void_t1841601450PK10MethodInfoPvPS2_ [RuntimeInvoker_Void_t1841601450?2(void**, undefined?S?*)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2375975:1 dynCall_iiii@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2391914:1 invoke_iiii@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:16492:10 __ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP15Il2CppException [il2cpp::vm::Runtime::Invoke?5(void**, undefined?S?*)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2048135:1 __ZN6il2cpp2vm7Runtime9ClassInitEP11Il2CppClass [il2cpp::vm::Runtime::ClassInit(Il2CppClass?*)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1244147:1 __ZN6il2cpp2vm6Object16NewAllocSpecificEP11Il2CppClass [il2cpp::vm::Object::NewAllocSpecific(Il2CppClass?*)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2036997:1 __ZN6il2cpp2vm6Object3NewEP11Il2CppClass [il2cpp::vm::Object::New(Il2CppClass?*)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2408539:1 _MySqlConnection__ctor_m3808450558@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2108894:1 _MySqlConnection__ctor_m3613524180@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2354919:1 dynCall_viii@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2399630:1 invoke_viii@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:16308:3 _MySQLCS_Awake_m3895412228@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1243601:1 __Z31RuntimeInvoker_Void_t1841601450PK10MethodInfoPvPS2_ [RuntimeInvoker_Void_t1841601450?2(void**, undefined?S?*)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2375975:1 dynCall_iiii@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2391914:1 invoke_iiii@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:16492:10 __ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP15Il2CppException [il2cpp::vm::Runtime::Invoke?5(void**, undefined?S?*)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2048135:1 _il2cpp_runtime_invoke@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2316460:1 __Z23scripting_method_invoke21ScriptingMethodIl2CppP15ScriptingObjectR18ScriptingArgumentsPP18ScriptingExceptionb [scripting_method_invoke?2()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2159309:1 __ZN19ScriptingInvocation6InvokeEPP18ScriptingExceptionb [ScriptingInvocation::Invoke(bool**)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1651100:1 __ZN19ScriptingInvocation6InvokeEPP18ScriptingException [ScriptingInvocation::Invoke(ScriptingException?**)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2376981:1 __ZN25ScriptingInvocationNoArgs13InvokeCheckedEv [ScriptingInvocationNoArgs::InvokeChecked()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2224158:1 __ZN13MonoBehaviour9CallAwakeEv [MonoBehaviour::CallAwake()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1645429:1 __ZN13MonoBehaviour12AddToManagerEv [MonoBehaviour::AddToManager()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1527525:1 __ZN9Behaviour13AwakeFromLoadE17AwakeFromLoadMode [Behaviour::AwakeFromLoad?1()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2114131:1 __ZN13MonoBehaviour13AwakeFromLoadE17AwakeFromLoadMode [MonoBehaviour::AwakeFromLoad?1()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1116289:1 __ZN18AwakeFromLoadQueue28InvokePersistentManagerAwakeEPNS_4ItemEj17AwakeFromLoadMode [AwakeFromLoadQueue::InvokePersistentManagerAwake?1(AwakeFromLoadQueue::Item*, unsigned int)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1514375:1 __ZN18AwakeFromLoadQueue30PersistentManagerAwakeFromLoadEv [AwakeFromLoadQueue:ersistentManagerAwakeFromLoad()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2114632:1 __ZN18LoadSceneOperation21CompleteAwakeSequenceEv [LoadSceneOperation::CompleteAwakeSequence()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1761793:1 __ZN18LoadSceneOperation25PlayerLoadSceneFromThreadEv [LoadSceneOperation:layerLoadSceneFromThread()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:675202:1 __ZN18LoadSceneOperation19IntegrateMainThreadEv [LoadSceneOperation::IntegrateMainThread()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1555292:1 __ZN14PreloadManager26UpdatePreloadingSingleStepENS_21UpdatePreloadingFlagsEi [PreloadManager::UpdatePreloadingSingleStep?N()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1652884:1 __ZN14PreloadManager35WaitForAllAsyncOperationsToCompleteEv [PreloadManager::WaitForAllAsyncOperationsToComplete()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2116478:1 __ZN19RuntimeSceneManager9LoadSceneERK8UnityStrS2_S2_RK9UnityGUIDiNS_11LoadingModeE [RuntimeSceneManager::LoadScene?2(UnityStr?S?&)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2032441:1 __Z21PlayerStartFirstSceneb [PlayerStartFirstScene(bool)]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:910201:1 __Z20PlayerLoadFirstScenev [PlayerLoadFirstScene()]@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:1991534:1 _main@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:922588:1 asm._main@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2453331:9 callMain@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2455394:13 doRun@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2455430:40 run/<@blob:null/4b3ba033-faff-4a2e-be37-6edc79724623:2455439:4
not sure if those dll's would work there, but even if they do, browser cannot do that kind of tcp connection.. you can use WWW class to connect into server, and have server side scripts to handle logins/user checkup etc.
Ok. I'm trying to use php on server side to connect to db. I want to use : http://wiki.unity3d.com/index.php/Server_Side_Highscores but I have an error: (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/WebGL/runtime/DebugBindings.gen.cpp Line: 51) Php scripts should be next to the index.html at public_html folder? What can be wrong?
php script should not relate with anything here mysql and many sql db normally use a port that not http. And that cannot be used on web browser directly. Unity WebGL cannot pass this restriction If you making php to connect with it. You need to expose that php tobe REST api and use it like calling any other REST api Hosting php on server making it not related to client code such as unity anymore. You cannot call php from unity. You can only call url that you make with your php on the server
Thanks for replay. This is not clear enought to me. I'm hosting my web gl app on serwer, and now i want to connect it with database on this serwer. I know that I can call only url php on the server. The problem is that , every user can call php script from url in browser? So, Should I make second app/script with database layer, put it on serwer and connect to main app? How to connect these 2 api? Could I please any example ?
some tips for securing the data in this thread, https://forum.unity3d.com/threads/webgl-and-php.432901/#post-2801006
@Smagacz If you already made php on your server and expose URL. Then your unity code should not aware about database at all. Your php should return data from url in json format. And your unity should just use class UnityWebRequest to call your php and get json data back By the means expose I mean you must do anything to make your php can be called from client by any user Do you know anything about AJAX? If you care about security. Then it's about how you secure your data. But in my opinion. REST API should be public data. And you make security by select only data that could let user know about to return to client You should make php being a gateway to client. You must not let client can do anything with your database from the client code directly