Using Gamelift Realtime with webgl Unity builds

0

I've got most of the process working but at the Client.connect() I come across this error in the webgl client:

SocketException: Success
System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) (at <00000000000000000000000000000000>:0)
--- End of stack trace from previous location where exception was thrown ---

this also occurs when trying to collect a local udp port (I simply set it to -1) which causes the error to occur later on at client.connect()

Thank you for any help!

已提問 1 年前檢視次數 365 次
1 個回答
0

Hi! It is not clear to me exactly from the error you've shared what is causing this issue, however, I hope that I can nevertheless assist.

You mentioned UDP in your post. Unfortunately, web browsers do not natively support communication over raw TCP sockets or UDP. They support WebRTC DataChannels for unreliable unordered messaging and WebSockets for reliable ordered messaging, but these are specific protocols running on top of TCP and UDP. I suspect that what's happening here is that the GameLift Realtime Client SDK / Unity tries to prepare for receiving packets on TCP or UDP, but this is not supported for WebGL builds and that's why it's throwing the error. As per Unity's own documentation about networking in WebGL:

Note that you can’t use .NET networking classes, because JavaScript code doesn’t have direct access to IP Sockets to implement network connectivity.

My current understanding is that because of this browser limitation, WebGL builds are not supported in GameLift Realtime either. However, there is one thing you can try; you can try passing a custom ClientConfiguration to the GameLift Realtime Server Client constructor. Try changing the connectionType to something else. If you're using RT_OVER_WS_UDP_UNSECURED, try using RT_OVER_WSS_DTLS_TLS12 or RT_OVER_WEBSOCKET.

AWS
Joris_D
已回答 1 年前
profile picture
專家
已審閱 12 天前
  • Thank you for the response, I suspected this was the issue.

    I was already using RT_OVER_WSS_DTLS_TLS12 and had thought since it was over wss (Websocket secured) it would work but I believe it utilizes unsecured socket types before making that final secured connection which is where the problem occurs.

    Regarding the UDP, I simply found that as the first cause of error but set a hard value instead of searching for it (which is of course not possible in webgl) - that lead to the next cause of error which was client.connect()

    Let me know if there is anything else I could do, thank you very much

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南