Unity 5.3.1.1f1 WebGL Connection problem

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

noveltysoft
Posts: 39
Joined: 19 Sep 2012, 03:24

Unity 5.3.1.1f1 WebGL Connection problem

Postby noveltysoft » 08 Mar 2016, 18:11

Hi,

I am trying to connect SFS through Unity 5.3.1 WebGL Connection, but its giving me following error:

blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:1 Uncaught abort(-1) at Error
at jsStackTrace (blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:1:22973)
at stackTrace (blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:1:23156)
at abort (blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:36:51480)
at _pthread_create (blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:1:206086)
at XF (blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:25:248173)
at TD (blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:25:225177)
at HM (blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:25:360499)
at LM (blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:25:363271)
at Lv (blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:25:86878)
at $vh (blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:7:802589)
If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.Browser.mainLoop.runIter @ blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:1Browser_mainLoop_runner @ blob:http%3A//192.168.0.100/86a783ef-6586-4bcb-9a2d-2abd4b45b87a:1

Can someone help me on this? I tried connecting directly with Unity Editor, it works but when compile the Build and run it through http://localhost/MyGame. It doesn’t work. Any suggestions? If its working in Unity Editor, it should work through Localhost too.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Unity 5.3.1.1f1 WebGL Connection problem

Postby Bax » 09 Mar 2016, 08:55

Can you try compiling and running one of our examples? The Connector example. Do you get the same issue?
What browser are you using? Did you enable Exceptions in the Publishing settings? Maybe you get a more readable error.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Unity 5.3.1.1f1 WebGL Connection problem

Postby Bax » 09 Mar 2016, 08:56

Also, if you can create a stripped down test project showing the issue, we can test it here too.
Paolo Bax
The SmartFoxServer Team
noveltysoft
Posts: 39
Joined: 19 Sep 2012, 03:24

Re: Unity 5.3.1.1f1 WebGL Connection problem

Postby noveltysoft » 09 Mar 2016, 14:52

Thankx for reply Bax.

I did enabled exceptions in publish settings and now it gives me following error along with the message i posted in my question.

warning: a problem occurred in builtin C++ name demangling; build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling
noveltysoft
Posts: 39
Joined: 19 Sep 2012, 03:24

Re: Unity 5.3.1.1f1 WebGL Connection problem

Postby noveltysoft » 09 Mar 2016, 14:57

i tried to run Connector example that u asked me to try.

when i tried that in my unity editor that gave me following error

[SFS > ERROR] [WebSocketLayer] Connection error: An exception has occurred while connecting. at WebSocketSharp.HttpBase.Read[HttpResponse] (System.IO.Stream stream, System.Func`2 parser, Int32 millisecondsTimeout) [0x00000] in <filename unknown>:0
at WebSocketSharp.HttpRequest.GetResponse (System.IO.Stream stream, Int32 millisecondsTimeout) [0x00000] in <filename unknown>:0
at WebSocketSharp.WebSocket.sendHttpRequest (WebSocketSharp.HttpRequest request, Int32 millisecondsTimeout) [0x00000] in <filename unknown>:0
at WebSocketSharp.WebSocket.sendHandshakeRequest () [0x00000] in <filename unknown>:0
at WebSocketSharp.WebSocket.doHandshake () [0x00000] in <filename unknown>:0
at WebSocketSharp.WebSocket.connect () [0x00000] in <filename unknown>:0
UnityEngine.Debug:Log(Object)
Connector:ShowLogMessage(String, String) (at Assets/ConnectorAssets/Scripts/Connector.cs:212)
Connector:OnErrorMessage(BaseEvent) (at Assets/ConnectorAssets/Scripts/Connector.cs:206)
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.SmartFox:ProcessEvents()
Connector:Update() (at Assets/ConnectorAssets/Scripts/Connector.cs:56)

and then i changed connection type in code to WSS from WS and port to 8843 and then it worked as fine as my own game is running in unity editor. but when i exported connector example as web GL build and tried in browser it gave me the following error :

blob:http%3A//192.168.0.100/0d37d005-c964-42fa-bd33-73144a6a172b:11931 WebSocket connection to 'wss://127.0.0.1:8843/websocket' failed: WebSocket opening handshake was canceled

where 192.168.0.100 is my local ip which i am using to run game in browser.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Unity 5.3.1.1f1 WebGL Connection problem

Postby Bax » 10 Mar 2016, 09:17

It is not clear why the Connector example shows a connection error saying that it can't connect to wss://127.0.0.1:8843, while the IP address should be 192.168.0.100. Did you change the IP in the example interface before clicking the Connect button?

As you are using a secure connection (WSS), maybe you can try the Advanced Connector example. You just have to edit the useEncryption flag (set it to true) in the code, then compile after the right IP and port and click the Connect button.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Unity 5.3.1.1f1 WebGL Connection problem

Postby Bax » 10 Mar 2016, 09:19

One more question... is there a reason why you think the original error you get when running your project in the browser (see your first post) is related to SmartFoxServer? Did you try to contact the Unity support too?
Paolo Bax
The SmartFoxServer Team
noveltysoft
Posts: 39
Joined: 19 Sep 2012, 03:24

Re: Unity 5.3.1.1f1 WebGL Connection problem

Postby noveltysoft » 10 Mar 2016, 13:18

i just updated server setting where i changed Web Server Socket Listener to 8443 from 8843 same as https port was 8443 by default. and after that added exception for insecure website in browser for https://192.168.0.100:8443. and now Connector example is working.

but i am still not able to go with my own project. the reason i think this error is related to SmartFoxServer because this error only occurs when i try to connect to sfs. otherwise everything is working fine. I am getting every Debug Log in my console before this statement

sfs.Connect(cfg);

right after this statement i am getting this error

warning: a problem occurred in builtin C++ name demangling; build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling

and then the one i have posted in my question.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Unity 5.3.1.1f1 WebGL Connection problem

Postby Bax » 10 Mar 2016, 14:15

Are you able to provide a test case (extracted from your project) showing the issue?
Otherwise it is impossible for us to debug. Maybe the Unity support can shed some light on the meaning of those errors.
Paolo Bax
The SmartFoxServer Team
noveltysoft
Posts: 39
Joined: 19 Sep 2012, 03:24

Re: Unity 5.3.1.1f1 WebGL Connection problem

Postby noveltysoft » 14 Mar 2016, 10:50

Hi,

Finally i figured out, there wasn't anything wrong with the code. the problem exists with the plugin i was using. i am posting this if any one else get into any problem like this could solve his/her problem. i was using one SmartFox2X.dll file and checked all the platforms for plugin. SfsWebSockets.jslib was missing in my project. So i created a WebGL folder inside plugins, copied SfsWebSockets.jslib and SmartFox2X.dll inside WebGL and only selected WebGL platform for this plugin. Rest of the code is same and everything is working now.

Thanks Bax for helping me figure out the problem.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Unity 5.3.1.1f1 WebGL Connection problem

Postby Bax » 14 Mar 2016, 11:55

Glad this is solved.
For future reference, the API setup for Unity (including WebGL build) is described on this page: http://docs2x.smartfoxserver.com/Gettin ... harp#unity
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 13 guests