Hello, I’ve decided to come to the community to see if anyone can make sense of why DTLS isn’t working on the Unity SDK of Gamelift Realtime. Instead of trying to explain the code in my project or possibly third party libraries in the project being the cause, I’ve created a very basic reproduction case that anyone can run and see the problem.
It’s a very simple project. On the Manager object there is a toggle for “Using TLS”. Then there are two different ways running this project will go:
Not Using TLS:
- Click “Create Game Session” Button. That will launch the create game session code as well connect to game session, etc. This will create a fast connection to a NON-cert session.
- Two messages will display on screen that this worked and the server will begin to send “KeepAlive” heart beats (counted in the upper right).
- Click “Join Group” Button. This will join Group 10, and begin to send you “GroupAlive” heart beats counted above KeepAlive.
- Type in the Input Field and then click “Send Message”. Obviously this will send the message to the server and it will be echoed back to the client and displayed with the other messages.
This for the most part works fine.
This is where things occur differently.
- Create Game Session will work and connect.
- Messages will display and heart beats will begin to count.
- Clicking “Join Group” will CRASH Unity and give the stack trace attached in error.log.
- Send Message however will work.
When using TLS, _client.JoinGroup(int) will cause Unity to fail.
Interestingly, if you switch SendMessagePayload(string) to use _client.SendEvent instead of a _client.SendMessage().WithDeliveryIntent(DeliveryIntent.Reliable), then Send Message will also crash. Or if you change DeliveryIntent to be Fast, it will crash.
My guess is that the base RTMessage Send function is not correctly identifying the connection type for the messages, nor is it correctly falling back to fast when reliable cannot be made. As well there isn’t error handling in place in the SDK to account for this.