I am currently trying to get an SSL connection setup on my multiplayer game in Unity. The connection itself seems to be working fine, but as soon as I try to use sfs.initCrypto(); after the successful connection I get an error message that says "Encryption initialization failed: An error occurred while sending the request". I'm not too sure where to go from here, so I am hoping posting on here will be of some help.
I am using Unity version 2020.2.1f1, SFS2X version 2.16.3 and C# API version 1.7.13.
On the server side logs, I don't get any errors besides the session being created and removed:
Code: Select all
27 Jan 2021
02:59:50,478 INFO SocketReader bitswarm.sessions.DefaultSessionManager Session created: { Id: 15, Type: DEFAULT, Logged: No, IP: x.x.x.x:63103 } on Server port: 9933 <---> 63103
27 Jan 2021
03:00:19,737 INFO SocketReader bitswarm.sessions.DefaultSessionManager Session removed: { Id: 15, Type: DEFAULT, Logged: No, IP: x.x.x.x:63103 }
27 Jan 2021
03:00:41,938 INFO SocketReader bitswarm.sessions.DefaultSessionManager Session created: { Id: 16, Type: DEFAULT, Logged: No, IP: x.x.x.x:63111 } on Server port: 9933 <---> 63111
27 Jan 2021
03:01:46,183 INFO Scheduler1-thread-1 bitswarm.sessions.DefaultSessionManager Session removed: { Id: 16, Type: DEFAULT, Logged: No, IP: x.x.x.x:63111 }
On the client side logs, I get the following:
Code: Select all
Connection established successfully
SFS2X API version: 1.7.13
Connection mode is: Socket
Encryption initialization failed: An error occurred while sending the request
And here is the code I am using in C# to connect and initialize the crypto:
Code: Select all
void Start()
{
//Start our SmartFox Instance
sfs = new SmartFox();
//Addd Event Listeners to our inital SmartFox Instance
sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
sfs.AddEventListener(SFSEvent.LOGOUT, OnLogout);
sfs.AddEventListener(SFSEvent.CRYPTO_INIT, OnEncrypted);
sfs.Connect(cfg);
}
public void OnConnection(BaseEvent evt)
{
if ((bool)evt.Params["success"])
{
sfs.InitCrypto();
}
else
{
Debug.Log("Connection failed");
}
}
void OnEncrypted(BaseEvent evt)
{
if((bool)evt.Params["success"])
{
Debug.Log("Encryption successful");
}
else
{
Debug.LogError("Encryption failed! Reason: " + (string)evt.Params["errorMessage"]);
}
}
I would also like to point out that I am working on a Mac whereas my friend is on PC and cannot reproduce this bug. I have also tested the SSL connection using the Advanced Connector Unity example as well, which results in the same outcome. Any help would be greatly appreciated