InitCrypto Intermittently Fails
InitCrypto Intermittently Fails
I've been using SFS2X for a couple months in development, and while testing we weren't using SSL. Now that we are starting to get ready for deployment we set up SSL certs for the server and related websites. Initially after installing the cert to the SFS2X installation InitCrypto connections appeared to be fine, albeit taking about 3x as long as a normal login request, however now the server appears to fail all encryption requests randomly before processing requests properly again. Is this standard behavior for a SFS2X deployment, or are there some settings I need to tweak? The returned error is not particularly descriptive -> Encryption initialization failed: An error occurred while sending the request -> so I'm uncertain if its simply timing out or if there is something else going on.
Re: InitCrypto Intermittently Fails
Hi,
we need more info to understand what might be going on.
- What version of SFS2X is being used
- client technology and client API version does the client use
- which side of the communication fails? Is it client or server side? Do you have specific error logs (with stack traces) related to these failures?
Have you found a way to reproduce the issue?
Does it happen at specific times (i.e. peak hours)?
Thanks
we need more info to understand what might be going on.
- What version of SFS2X is being used
- client technology and client API version does the client use
- which side of the communication fails? Is it client or server side? Do you have specific error logs (with stack traces) related to these failures?
Have you found a way to reproduce the issue?
Does it happen at specific times (i.e. peak hours)?
Thanks
Re: InitCrypto Intermittently Fails
Using SFS2X 2.14.0
Client side is C# using Unity, the client side is the side that fails. I'm not certain where to find the client API version, there isn't anything in the readme files in the package downloaded from the SFS website, however the client side files were downloaded in Jan 2020.
Client side will fail seemingly at random with the following stack trace, the server does not print any trace :
[SFS > ERROR] Encryption initialization failed: An error occurred while sending the request
UnityEngine.Debug:Log(Object)
ACA.iD.Collaborate.SFSLoginUtility:ShowLogMessage(String, String) (at Assets/iDCollaborate/Scripts/Connection/SFSLoginUtility.cs:217)
ACA.iD.Collaborate.SFSLoginUtility:OnCryptoInit(BaseEvent) (at Assets/iDCollaborate/Scripts/Connection/SFSLoginUtility.cs:158)
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.SmartFox:ProcessEvents()
ACA.iD.Collaborate.SmartFoxConnection:Update() (at Assets/iDCollaborate/Scripts/Connection/SmartFoxConnection.cs:29)
I tested the SSL certificate with an ssl checker (https://www.sslshopper.com/ssl-checker.html) recommended in another post related to InitCrypto issues, and it returns that the SSL cert is valid.
EDIT: I will note that regardless of whether the encryption succeeds or fails it takes a significantly longer time to return from the server than login without encryption, about 15 seconds longer.
Also I just updated the client API to 1.7.13 and the problem persists
Client side is C# using Unity, the client side is the side that fails. I'm not certain where to find the client API version, there isn't anything in the readme files in the package downloaded from the SFS website, however the client side files were downloaded in Jan 2020.
Client side will fail seemingly at random with the following stack trace, the server does not print any trace :
[SFS > ERROR] Encryption initialization failed: An error occurred while sending the request
UnityEngine.Debug:Log(Object)
ACA.iD.Collaborate.SFSLoginUtility:ShowLogMessage(String, String) (at Assets/iDCollaborate/Scripts/Connection/SFSLoginUtility.cs:217)
ACA.iD.Collaborate.SFSLoginUtility:OnCryptoInit(BaseEvent) (at Assets/iDCollaborate/Scripts/Connection/SFSLoginUtility.cs:158)
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.SmartFox:ProcessEvents()
ACA.iD.Collaborate.SmartFoxConnection:Update() (at Assets/iDCollaborate/Scripts/Connection/SmartFoxConnection.cs:29)
I tested the SSL certificate with an ssl checker (https://www.sslshopper.com/ssl-checker.html) recommended in another post related to InitCrypto issues, and it returns that the SSL cert is valid.
EDIT: I will note that regardless of whether the encryption succeeds or fails it takes a significantly longer time to return from the server than login without encryption, about 15 seconds longer.
Also I just updated the client API to 1.7.13 and the problem persists
Re: InitCrypto Intermittently Fails
Hi,
are you sure it's taking 15 seconds for the initCrypto to complete? I ask because 15 seconds is way too much and it should probably cause a timeout error.
We have tested an SSL connection in Unity from our connection in Italy to a server in the U.S. (so not exactly around the corner) and it takes around 1.5 seconds to connect + init TLS + login into a Zone. The initCrypto alone takes ~970ms.
Have you tried testing from both the Unity Editor and the built executable to see if there's any difference?
Are your client tests done from the same network or did you try different ones?
Where are the server and client locate? (country / state)
Thanks
are you sure it's taking 15 seconds for the initCrypto to complete? I ask because 15 seconds is way too much and it should probably cause a timeout error.
We have tested an SSL connection in Unity from our connection in Italy to a server in the U.S. (so not exactly around the corner) and it takes around 1.5 seconds to connect + init TLS + login into a Zone. The initCrypto alone takes ~970ms.
Have you tried testing from both the Unity Editor and the built executable to see if there's any difference?
Are your client tests done from the same network or did you try different ones?
Where are the server and client locate? (country / state)
Thanks
Re: InitCrypto Intermittently Fails
One more thing. What happens if you just point your browser to https://your-server-domain:8443 ?
In theory you should see the SFS2X welcome page appear instantly.
Thanks
In theory you should see the SFS2X welcome page appear instantly.
Thanks
Re: InitCrypto Intermittently Fails
When the CRYPTO_INIT event is fired, you have access to two parameters: "success" and "errorMsg".
What error message are you getting?
What error message are you getting?
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: InitCrypto Intermittently Fails
@Lapo - I've double checked the full login pipeline, it looks like another engineer stuck a long awaitable in the callback chain, relocating that awaitable reduced the crypto callback to be the same 1s as the normal login call, sorry about that. The build version and the editor version have the same issues and have been tested on 7 different networks. The server is located in Oregon, USA, the test connections are being made from Kansas, USA.
Additionally going to https://mydomain.com:8443 does show the welcome page with the secure lock to indicate the SSL was successful and loads reasonably quickly.
@Bax - The error message I posted above is the errorMessage "An error occurred while sending the request", trying to echo out evt.Params["errorMsg"] returns a key not found exception
This is my CRYPTO_INIT event reciever :
Additionally going to https://mydomain.com:8443 does show the welcome page with the secure lock to indicate the SSL was successful and loads reasonably quickly.
@Bax - The error message I posted above is the errorMessage "An error occurred while sending the request", trying to echo out evt.Params["errorMsg"] returns a key not found exception
This is my CRYPTO_INIT event reciever :
Code: Select all
private void OnCryptoInit(BaseEvent evt)
{
if ((bool)evt.Params["success"])
{
ShowLogMessage("INFO", "Encryption initialized successfully");
// Attempt login
login();
}
else
{
//onFailure?.Invoke("Encryption initialization failed: " + (string)evt.Params["errorMessage"]);
ShowLogMessage("ERROR", "Encryption initialization failed: " + (string)evt.Params["errorMessage"]);
}
}
Last edited by evfaca on 10 Apr 2020, 14:31, edited 1 time in total.
Re: InitCrypto Intermittently Fails
evfaca wrote:@Bax - The error message I posted above is the errorMessage, trying to echo out evt.Params["errorMsg"] returns a key not found exception
Pay attentions to the key: it's errorMsg, not errorMessage.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: InitCrypto Intermittently Fails
@Bax - I printed every key I get from evt
success : False
errorMessage : An error occurred while sending the request
There isn't an errorMsg being returned
Debug Code:
EDIT : I've double checked the C# API documentation, http://docs2x.smartfoxserver.com/api-do ... 9100fd.htm and http://docs2x.smartfoxserver.com/Exampl ... -connector both show the returned error key as errorMessage.
success : False
errorMessage : An error occurred while sending the request
There isn't an errorMsg being returned
Debug Code:
Code: Select all
foreach (KeyValuePair<string, object> par in evt.Params)
{
Debug.Log("Param : " + par.Key + " : " + par.Value);
}
EDIT : I've double checked the C# API documentation, http://docs2x.smartfoxserver.com/api-do ... 9100fd.htm and http://docs2x.smartfoxserver.com/Exampl ... -connector both show the returned error key as errorMessage.
Re: InitCrypto Intermittently Fails
You are right, sorry, my fault. The parameter is "errorMessage".
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: InitCrypto Intermittently Fails
That useful error message ("An error occurred while sending the request") is returned by the exception raised when the connection to initialize encryption is attempted by this code inside the API:
So everything relies on System.Net.Http.HttpClient. We are still not sure why you get that random behavior.
Code: Select all
try
{
var req = await httpClient.PostAsync ("", formContent);
req.EnsureSuccessStatusCode();
string res = req.Content.ReadAsStringAsync().Result;
OnHttpResponse (res);
}
catch (Exception ex)
{
OnHttpError (ex.Message);
}
So everything relies on System.Net.Http.HttpClient. We are still not sure why you get that random behavior.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: InitCrypto Intermittently Fails
@evfaca:
Can you send us the IP address of the server? So we can run a few connection tests from remote?
Also send us a valid zone and credentials for the login.
You can use a forum private message, or get in touch via our support@... email box. (if you use the latter please add a reference to this discussion)
Thanks
Can you send us the IP address of the server? So we can run a few connection tests from remote?
Also send us a valid zone and credentials for the login.
You can use a forum private message, or get in touch via our support@... email box. (if you use the latter please add a reference to this discussion)
Thanks
Re: InitCrypto Intermittently Fails
Send you a PM @Lapo
Re: InitCrypto Intermittently Fails
After coordinating with Lapo via PM, this problem has been solved. Ultimately the issue was I was using the IP of the server to connect rather than the hostname.
Who is online
Users browsing this forum: No registered users and 24 guests