Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Remote Connection issues and problems implementing service...multiple questions
June 2, 2017
13:50, EEST
Avatar
DrD2k3
Member
Members
Forum Posts: 3
Member Since:
June 2, 2017
sp_UserOfflineSmall Offline

I am using C++ Builder 10.1.2 Berlin and Prosys Sentrol 6.7.1 Build 656.

I have implemented a server application that has to broker data between DDS, Modbus and OPC data streams.

I am now at a stage where if I run our data broker server app I can use either our test client or the Prosys OPC Client app to see our app registered as an OPC server and to connect to it and receive data from it but this is if I run client and server on the same PC.

I have DCOM configured correctly, I beileve, on 2 PCs. I verified DCOM was working by using the Prosys Simulation Server on one PC and the Prosys OPC Client on the other. The client can connect to either the Prosysy OPC Service or the Server app and receive data.

After some restructuring of our app, such as to create the OPC provider before Application->Initialize() is called I managed to get it so a remote client on a different PC could see, connect and receive data from our server app.

I have noticed something. When I start the server app and on the same PC start a client, this client will connect to the already running instance of the server app. If I shut the client down my server app keeps running as expected. If I connect to our server app from a remote PC then the client on the remote side doesn’t connect to the running instance of our server but instead a new instance is spawned in the background when the remote client connects. Due to the nature of our server app we only want one instance running on a PC.

Therefore, is there a way to stop this behaviour? Can I get it so the remote client will connect to the already running instance of our server app?

I also have noticed if I run our app manually and shut it down, it does so cleanly. Whereas when I let the remote client spawn an instance of our server on the server PC (with no other instances running) then when the client closes and remotely “kills” the spawned server the server app gets an abnormal program termination. From our debug logging I can see all the objects we create have been destroyed correctly but it seems some where around destroying the OPC Provider it goes wrong but I’m not 100% clear as to what is happening yet.

I thought one way around this would be to convert our app to a service. So I have created a service project using builder and followed the Delphi source code for the Prosys OPC Service that comes with the simulation server.

I have a service that installs, registers itself for DCOM and runs (I have debug logging and can see it handling incoming DDS data and republishing as OPC data). Comparing the settings for Prosys OPC service and our service in DCOMCNFG they have identical settings. Also comparing our service’s settings against the Prosys service in the services management console in window they have the same settings.

But I have a big problem with our service. No clients can connect to it, on the same PC or from a remote one. After a long timeout the client displays an error message of the form: Cannot connect to OPC Server #######: Server execution failed, ClassID: {#######}.

What could be causing this problem?

I see the Prosys OPC Service is running in the background all the time and the client just connects to this without issue.

I am not using DelayInitialize with our service but was instead am using the same technique as in our server app and creating the OPC provider before Application->Initialize() is called in the services Main function. Is this correct or should I be using DelayInitialize =true and create the OPC Provider in our TService objects OnCreate?

Ideally I’d like to get our service working as the proper solution. I don’t have much time left to get this fully working so any help would be very much appreciated.

I can provide code snippets if it helps.

June 2, 2017
16:48, EEST
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hello Duncan,

Thank you for contacting us here in the support forum. As you mentioned in your email yesterday evening, there’s probably been an issue with emails.

You should have received an email about this matter on Monday 29th and Thursday 1st but you have not probably seen these messages. I resent the related messages just now. Please let us know if you have any further questions after looking at these emails.

June 2, 2017
17:20, EEST
Avatar
DrD2k3
Member
Members
Forum Posts: 3
Member Since:
June 2, 2017
sp_UserOfflineSmall Offline

Thanks. I have the emails now.

Since I sent my emails I managed to overcome some of the issues. So my description in my post above is where I’m currently at.

Using my server application I can connect locally and remotely and get data. But as described above I see that when doing this the remote client connecting in causes a new instance of the server app to be spawned in the background rather than using the instance that was started manually by me on the server PC.

As for the service, I have it so it has all the exact same settings shown in the services management window as the Prosys OPC Service. The mistake I had made was to not add the registry settings in the ServiceAfterInstall event handler like shown in the source code for your Prosys Service. So our service is set to run automatically it is set to log on as local system account, just like your Prosys Service.

If I look under DCOMCNFG then we now have similar settings to the Prosys Service, e.g. Authentication: Default, App Type: Local Service, Location: Run application on this Computer, Security settings are identical, as are endpoints and identity is set as The system account (services only).

I see our service listed in the Prosys Client’s list of servers but when I try to connect to the service it just times out and I get the error I emailed to you last night.

Hence my post above I wondered if I’ve set my service correctly in the code regarding when I create the OPC provider and DelayInitializd setting.

June 5, 2017
15:15, EEST
Avatar
DrD2k3
Member
Members
Forum Posts: 3
Member Since:
June 2, 2017
sp_UserOfflineSmall Offline

Just a quick update in case anyone is interested in how I have fixed the issues we were having as I have now managed to get everything working correctly.

We can now connect to our service and standalone server app locally and remotely with the Prosys OPC Client app and our own client test app.

Standalone server app works and shuts down cleanly when being automatically launched/closed on client connection/disconnection. I had to take into account the order in which objects get destroyed to make sure the OPC Provider wasn’t killed before tidying up the other objects that had any dependence on it.

Service works fine, I had to set DelayInitialize to true and create the OPC Provider in the service’s OnCreate handler and destroy it in the service’s OnDestroy handler. The rest of our service app follows a similar structure to the Delphi code included with the Prosys SImulation Server’s service project.

June 7, 2017
17:47, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 963
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Thanks a lot for confirming that you got it working. DCOM and services can be tricky to get configured properly in practice, but good to know that you managed!

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
9 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 124

pramanj: 86

ibrahim: 74

rocket science: 65

kapsl: 57

Sabari: 51

gjevremovic: 49

Xavier: 43

fred: 41

TimK: 41

Member Stats:

Guest Posters: 0

Members: 684

Moderators: 15

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1335

Posts: 5711

Newest Members:

daniel.boada@soprasteria.com, Ratheesh, Dustingen, janessawhittell, ravi_prabhakar, dustyy137676428, Douglasabibe, DonaldWibip, kennithmazza4, Heiko Geissler

Moderators: Jouni Aro: 963, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 877, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 25, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 230, Lusetti: 0

Administrators: admin: 1