Not working at all :(
Closed this issue · 15 comments
I'm sending ~2500 byte long message in one process once a second on Windows 7.
I'm trying to receive messages in 10 other processes.
The first receiver kind of starts to receive messages, but drops many of them. Other processes are not really receiving anything, sometimes they receive a message, then it all stops receiving, this is terrible :(
Did anyone use this in production or is this some kind of a school project? :(
Any other IPC I can use??
IPC messaging isn't my area of expertise, I had a problem and had to come up with a solution. Personally I'm mostly using it on Windows 10 primarily between one or two clients that may or may not be running and I'm sending very short messages (like 20-30 bytes at most).
You're welcome to suggest improvements.
Hey David,
I tested it on Win 10, works great! So it doesn't work only on windows 7 :(
Any ideas what it could be? EventWaitHandle?
Since it's working sometimes, and sometimes not, I'm thinking it may be because my Win 7 computer is kind of slow. There are lots of Task.Factory.StartNew and maybe you're expecting this to execute very quickly, it may be some kind of timing issue.
Hmm, when you posted yesterday I realized I've barely paid any attention to this code in years so I started making some improvements. Task.Factory.StartNew
is bad, it's supposed to be Task.Run
and I did discover a bug while refactoring the unit tests and I've made some other improvements but I haven't pushed anything yet. The code could certainly be improved to be more performant as well.
Last night I tested it with up to 12 clients without any issues, but that was on Windows 10. I don't have any Windows 7 machines, not with developer tools installed anyway, so I have no idea how to debug the problems you describe. I'll have to investigate Microsofts documentation, I thought all the primitives would work on any version on Windows.
messagebus2.MessageReceived += (sender, e) =>
received = Encoding.UTF8.GetString(e.Message);
The received line is not executing :( Only sometimes when I use debugger and I step thru the code, it executes, that give me the idea, it's somehow related to timing of some events
I've pushed a few changes now, nothing revolutionary but the lock tests should be better now. I've also pushed a branch called some-improvements
where I refactored the TinyMessageBus somewhat. Could you try it out and see if any of it makes any difference?
I'm also thinking of removing the publish queue in TinyMessageBus altogether and replace it with a Task based API instead. The lock and the memory mapped file will probably stay syncronous because the primitives involved are inherently synchronous anyway.
I pushed another branch called task-based-publish
with the latter changes as well, it greatly simplified the message bus and I kind of like it.
That's cool, you should use whatever works best for you.
I'm sad to say I am unable to reproduce or figure out the stuck tests you describe, I have run the tests many many times on three different machines and they never get stuck for me, not even om my pretty slow Surface Go.
If you have the time it would be helpful if you could run one of the tests that get stuck with the debugger, pause when it's stuck and screenshot the full Parallel Stacks view and perhaps the Tasks view in Visual Studio. You can find it under the Debug > Windows menu while debugging. Thanks.
Thank you, that was very helpful.
I think the problem was that I was using the shared EventWaitHandle that lives in TinyMemoryMappedFile to signal disposal of the class, that works fine as long as there is only one instance but when there are more instances in the same process or even on the same computer, which is kind of the entire point of this project, then things get messy and I think there may have been some race conditions there which caused issues.
I have pushed a new commit to the tasked-based-publish
branch which is using a separate internal EventWaitHandle to signal disposal which should be perfectly safe.
Same issue here on our app run on Windows 7.
@DavidZidar will this commit come to Nuget soon? Since we are almost ready to release our app :D
--- I've verified "tasked-based-publish" on win7 works well!
Thank you very much!
I just published version 2.0.0 to nuget.org, the release notes can be found here
https://github.com/steamcore/TinyIpc/releases/tag/2.0.0
Thanks a lot!