WebGL Connection issue from Unity C#

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

Moderators: Lapo, Bax

Posts: 6
Joined: 06 Jan 2016, 19:05

WebGL Connection issue from Unity C#

Postby anicholas » 07 Jan 2021, 22:58


We have a legacy app that runs on Windows, Mac, and previously the Unty Webplayer. As we've been recently updating it, we've obviously deprecated the webplayer and have been working towards getting it working with WebGL.

Our SFS client connection code works and has been working. It even works in the Unity Editor when WebGL is the current active platform. When I attempt to connect when running the WebGL build through the browser (hosted on one of our test servers), it seems to hang without any error.

Originally it was trying to connect using the standard 9933 socket port, but I've seen attempted to utilize the ws/wss port instead with no luck.

I've attached some screen shots of what settings I have and what I'm seeing on my end.
(17.41 KiB) Not downloaded yet
(61.29 KiB) Not downloaded yet
(52.67 KiB) Not downloaded yet
User avatar
Site Admin
Posts: 21782
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: WebGL Connection issue from Unity C#

Postby Lapo » 08 Jan 2021, 08:34

in order for the SFS2X client API to use websocket you need to call a specific constructor of the SmartFox class, which I don't see in your code snippets.

In short:

Code: Select all

var smartfox = new SmartFox(UseWebSocket.WS_BIN)

More details can be found in the API docs here:
http://docs2x.smartfoxserver.com/api-do ... 0f098f.htm

Are you using this?
...addicted to flash games
Posts: 6
Joined: 06 Jan 2016, 19:05

Re: WebGL Connection issue from Unity C#

Postby anicholas » 08 Jan 2021, 15:34

Thanks Lapo! I'll give this a try, I'm pretty sure we aren't using that currently.

Yep, that was it. I had to also upgrade our Client dll to 1.7.x to be able access that constructor since we were still on 1.5.x, but all it's connecting now! Thanks again.

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 6 guests