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 Jeff,
I have developed a UpdateProcessor that reads Google calendar using Google Restful API. For that, it reads a ‘client_secret.json’ file from my machine. This SmartConnector works from Test Explorer in developer studio.
However, when I deploy it on the SmartConnector Portal on my machine. The Update Processor expects file in C:\windows\System32 folder. I copy the file to that folder but getting System.IO.FileNotFoundException:
“System.IO.FileNotFoundException: Could not find file 'C:\windows\system32\client_secret.json'.
File name: 'C:\windows\system32\client_secret.json' at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at SmartConnector.Extension.RCSI.UpdateProcessor.ReadGoogleCal()
at SmartConnector.Extension.RCSI.UpdateProcessor.Execute_Subclass()
I try couple of things but they didn’t work either:
2. Give all the permissions to the file for all the user in C:\Windows\system32. Still file not found exception.
3. I can’t change permission at system32 folder level.
I wonder if SmartConnector has any limitation imposed to read .json file. Please advise.
Thanks!
Neeraj Tomar
Link copied. Please paste this link to share this article on your social media post.
Hi Neeraj,
First, Smart Connector has NO limitations about reading .json files. It can read anything, in fact I have done something with Google credentials .json files very recently and it worked as expected.
As you are seeing, the user who is running the Smart Connector service (by default this is the SYSTEM user), needs to have access to the file and the directory where you are storing it.
I would recommenced not hard coding the location but allowing the user to supply exactly where they want the file to be. I also recommend, setting the default to something like ProgramData where you know the SYSTEM user will have access.
For example:
$"{Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)}\SmartConnector\ExtensionName\credentials.json"
In general, putting anything directly onto the C drive, or into the System32 folders are bad design, as both of these places are locked down pretty tight by the operating system. It may work with the test explorer in Visual Studio because Visual Studio may be running as admin and has more rights than the SYSTEM user which the Smart Connector Service is running as.
As far as the hanging, I would make sure that you are checking your CancellationToken in parts of your code that can take a long time to execute, and if the user has asked for a cancellation, then return and end the processor execution.
Regards,
-Jeff
Link copied. Please paste this link to share this article on your social media post.
Hi Neeraj,
First, Smart Connector has NO limitations about reading .json files. It can read anything, in fact I have done something with Google credentials .json files very recently and it worked as expected.
As you are seeing, the user who is running the Smart Connector service (by default this is the SYSTEM user), needs to have access to the file and the directory where you are storing it.
I would recommenced not hard coding the location but allowing the user to supply exactly where they want the file to be. I also recommend, setting the default to something like ProgramData where you know the SYSTEM user will have access.
For example:
$"{Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)}\SmartConnector\ExtensionName\credentials.json"
In general, putting anything directly onto the C drive, or into the System32 folders are bad design, as both of these places are locked down pretty tight by the operating system. It may work with the test explorer in Visual Studio because Visual Studio may be running as admin and has more rights than the SYSTEM user which the Smart Connector Service is running as.
As far as the hanging, I would make sure that you are checking your CancellationToken in parts of your code that can take a long time to execute, and if the user has asked for a cancellation, then return and end the processor execution.
Regards,
-Jeff
Link copied. Please paste this link to share this article on your social media post.
Thank you for your response. I used the 'SpecialFolder.CommonApplication' path that fixed reading json file issue. Other issue, I was having was reading credential file from user\my documents folder. By adding logging, I figured out that reading path using below API:
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
was giving me blank when the extension is deployed on the smartconnector portal. In testing environment, path was C:\Users\sesaxxx\Documents\.credentials. Changing this path also to CommonApplication folder fixed the problem.
Regards,
Neeraj Tomar
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.