hhblaze / SharmIPC

IPC [inter-process communication] engine for .NET based on memory-mapped files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SharmIPC not working within a service

Sheol83 opened this issue · comments

Hello,

to me it looks like SharmIPC won't work when the implementation is run as a service. I usually have a project with the implementation, accompanied by a console project (for testing) and the service project. Normally the first started console project registers as a MASTER and the second console project as a SLAVE. When running these projects as a service they don't seem to know each other. Both of them register as MASTER and they can't communicate. Is there any solution to this?

commented

Try to setup "Global/mySharmIpcName"

//from here https://github.com/hhblaze/SharmIPC
unique name must start from the prefix "Global/" to make communication available
for processes executed by different OS users

Okay, I've tried that but the client process still logs:
"tiesky.com.SharmIpc: Master of Global/GetCurveWithDate"

Is there maybe anything I need to consider when running the SharmIpc host as s service?

commented

ok... that needs extra investigations, try to start your service under the same user as client, and let me know the result

Smth. like (Screenshot with Russian chars, but must be clear):

image

commented

Try also under other user account (than the client account) (with "/Global") and let me know. I think this should definitely work. We got one such service running under Administrator account and many clients started under different credentials. Problem can b LocalSystemAccount

Thank you for your support so for!

Our services are always running under a specific user. So normally I would assume my services are in the same scope and should be able recognize each other?

What is the best practice for hosting it as a service? Currently I have put it in a "ServiceHost" instance which is normally used for WCF services. So I guess this is not the ideal way of doing this? Maybe the connection is closed immediately after creation so the client is in fact the only "master"?

                var serviceHost = new SmartIpcServiceHost(); // This host class creates the "SharmIpc" instances and contains the event handlers
                _host = new ServiceHost(serviceHost);
                _host.Open();
commented

Have no idea about best practice...it's just MemoryMappedFiles inside and inter-process mutexes.
What is about just 2 console applications test and current release version, does it run in your environment (under that user who hosts the service)?

commented

btw, I have just published newest version 1.12, make other test with this one, please

It works now! I'm not absolutely sure why but maybe because of the new version. Thanks a lot! :-)

commented

Very well!