SmartConnector Forum
Schneider Electric support forum about SmartConnector applications for integration of other building management systems (BMS) into EcoStruxure Building Operation.
Link copied. Please paste this link to share this article on your social media post.
Hi,
We have a customer who have created an endpoint in SmartConnector, but our SmartConnector cannot obtain a token.
See the error below.
2021-09-09 00:00:00.3049,Error,RestServe,<no principal>,One or more errors occurred.
An error occurred while sending the request.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:8083
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at Mongoose.Common.Security.BearerToken.ObtainToken(Uri baseAddress, String username, String password, String tokenActionName)
,[],
We are able to login to the SmartConnector Swagger using the username and password that we use our SmartConnector extension.
Any idea what may cause this issue?
Thanks.
Mike
Link copied. Please paste this link to share this article on your social media post.
This looks like a misconfiguration issue. Please turn on trace logging (and EWS consume) and attach the resulting log.
Also, please provide a screenshot of the REST configuration and the consuming client code.
BR
Armend
Link copied. Please paste this link to share this article on your social media post.
Hello Armend,
See the code below that is used to obtain a token.
See the log that is created when this function is called.
Any idea what may be the problem. In most cases this is working fine.
2021-09-07 13:31:05,852 [1] INFO SEEwsRestApi - Init...
2021-09-07 13:31:05,852 [1] INFO SEEwsRestApi - Init, url = 'http://127.0.0.1:8083/SBO/', user = 'smartconnector', password ´*****'
2021-09-07 13:31:05,852 [1] INFO SEEwsRestApi - ObtainBearerToken uri = 'http://127.0.0.1:8083/SBO/', user = 'smartconnector', pass = '*******'
2021-09-07 13:31:07,212 [1] ERROR SEEwsRestApi - ObtainBearerToken fail, token is empty or null
2021-09-07 13:31:07,212 [1] INFO SEEwsRestApi - Init ended, rc = '-4'
public static int ObtainBearerToken ()
{
_bearerToken = null;
try
{
// Obtain Token
Uri uri = new Uri(Settings.m_strURL);
_log.InfoFormat("ObtainBearerToken uri = '{0}', user = '{1}', pass = '{2}'", uri.ToString(), Settings.m_strUser, Settings.m_strPassword);
_bearerToken = BearerToken.ObtainToken(uri, Settings.m_strUser, Settings.m_strPassword, "GetToken");
if (_bearerToken == null)
{
_log.ErrorFormat("ObtainBearerToken fail, token is empty or null");
return -4; // invalid token
}
_log.InfoFormat("ObtainBearerToken pass, token = '{0}'", _bearerToken.ToString());
return 0;
}
catch (Exception ex)
{
_log.ErrorFormat("ObtainBearerToken, Exception, msg = '{0}'", ex.Message);
return -4;
}
}
Thank you.
Mike
Link copied. Please paste this link to share this article on your social media post.
If it works sometimes and sometimes not without anything changed, it's 99% EBO session exhaustion when using http. Try using a https connection to EBO and it'll work fine.
BR
Armend
Link copied. Please paste this link to share this article on your social media post.
Hi Armend,
Thank you for your answer. Before suggesting it to the customer I have one question and one problem.
1. Why it is not working using HTTP?
2. I have created a certificate for the EBO and I am able to login to the EBO using this certificate. When I change the processor settings to HTTPS (https://192.168.1.24:444/EcoStruxure/DataExchange) I get an exception the the SmartConnetcor log and the processor won't start. See below. Can you tell me what's wrong with the certificate?
2021-09-23 17:04:13.9425,Error,Processor,<no principal>,EBO OPC Item Discovery Processor,System.ServiceModel.Security.SecurityNegotiationException: Could not establish trust relationship for the SSL/TLS secure channel with authority '192.168.1.24:444'. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
Thank you.
Mike
Link copied. Please paste this link to share this article on your social media post.
Hi Armend,
I found the reason for HTTP not working. The server address was incorrect.
It was:
http://localhost:3280/EcoStruxure/DataExchnage
Instead of:
http://localhost:3280/EcoStruxure/DataExchange
"DataExchnage" instead of "DataExchange"
However, I am still unable to use HTTPS. I am getting the exception below. Any idea why?
2021-09-23 17:04:13.9425,Error,Processor,<no principal>,EBO OPC Item Discovery Processor,System.ServiceModel.Security.SecurityNegotiationException: Could not establish trust relationship for the SSL/TLS secure channel with authority '192.168.1.24:444'. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
Thank you.
Mike
Link copied. Please paste this link to share this article on your social media post.
Hi,
It looks like your certificate isn't valid. Usually you can tell if EBO asks you to "Trust certificate anyway" at login. You'll have to create a valid certificate and install it on your computer.
BR
Armend
Link copied. Please paste this link to share this article on your social media post.
HI Armend,
Thank you for your answer. The certificate was installed and trusted and the EBO does not ask me to trust it when I login. So from the EBO point of view the certificate works fine.
The only problem is when I try to start the SmartConnector processor. See the exception below.
{"ClassName":"System.ServiceModel.Security.SecurityNegotiationException","Message":"Could not establish trust relationship for the SSL/TLS secure channel with authority '192.168.1.24:444'.","Data":null,"InnerException":{"ClassName":"System.Net.WebException","Message":"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.","Data":null,"InnerException":{"ClassName":"System.Security.Authentication.AuthenticationException","Message":"The remote certificate is invalid according to the validation procedure.",
See the attached screen capture. How can I check what is the problem with the certificate?
Thanks.
Mike
Link copied. Please paste this link to share this article on your social media post.
Could be a lot of things.
Is 444 the HTTPS port EBO is using?
Link copied. Please paste this link to share this article on your social media post.
Yes,
444 is the HTTPS port. See attached screen capture.
Thanks.
Mike
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.