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!

질문됨 일 년 전353회 조회
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
답변함 일 년 전
profile picture
전문가
검토됨 8일 전
  • 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

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠