[en] Connect to IpcBinary channel under IIS always says "Failed to connect to an IPC Port: Access is denied" (solved)

Topics: Technical Support
Nov 10, 2014 at 2:05 PM
const string IpcPortName = "AnyValidFilename";

const string ZyanHostName = "SampleService";

// ------------------------------- Server code --------

    static void RunServer()
    {
        var protocol = new IpcBinaryServerProtocolSetup(IpcPortName);
       //protocol.UseWindowsSecurity = false;
        using (var host = new ZyanComponentHost(ZyanHostName, protocol))
        {
            host.RegisterComponent<ISampleService, SampleService>();
            Console.WriteLine("Server started. Press ENTER to quit.");
            Console.ReadLine();
        }
    }
client under IIS website
const string IpcPortName = "AnyValidFilename";

const string ZyanHostName = "SampleService";

var protocol = new IpcBinaryClientProtocolSetup();
//protocol.UseWindowsSecurity = false;
var url = protocol.FormatUrl(IpcPortName, ZyanHostName);

        using (var conn = new ZyanConnection(url, protocol))
        {
            Console.WriteLine("Connected to server.");
            var proxy = conn.CreateProxy<ISampleService>();
                   ...........................................
        }
Stack Trace:
[RemotingException: Failed to connect to an IPC Port: Access is denied. ]
ZyanConnection..ctor(String serverUrl, IClientProtocolSetup protocolSetup, Hashtable credentials, Boolean autoLoginOnExpiredSession, Boolean keepSessionAlive) in E:\test\ZyanConnection.cs:253
Coordinator
Nov 10, 2014 at 3:34 PM
Hi,

Looks like a permission-related issue to me.
Does the same code work when you run it within two separate console applications, not from IIS?

Check what user account is your IIS service running under.
Try connecting from the process running under the same user.

Let me know if it helps.
— Alex
Nov 10, 2014 at 4:23 PM
Edited Nov 10, 2014 at 4:27 PM
Hi, yallie
   Zyan is amazing , I like it !  Also thank you for your fast reply !
Does the same code work when you run it within two separate console applications, not from IIS?
yes, two console applications work well.
Check what user account is your IIS service running under.
Try connecting from the process running under the same user.
you're right, that's the problem. the server console is running under Admin ,
but website is running under IIS apppool ID.

as for security problems , website usually running under lower permission account,
so is it possible the server and client ( IPC channel) work under different user ID?
Coordinator
Nov 10, 2014 at 10:23 PM
Zyan is amazing , I like it ! Also thank you for your fast reply !
 
Thanks, you're very kind!
 
so is it possible the server and client ( IPC channel) work under different user ID?
 
Frankly, I don't know, never tried this scenario myself.
I'd probably use TCP channel if I couldn't get IPC to work in such circumstances.
I don't think that performance would degrade noticeably.

PS. Guys at Microsoft suggest that channel setting exclusiveAddressUse="False" might help.
Please try using it on both sides (client and server) and let me know if it helps.
The usage is like this:
var protocol = new IpcBinaryServerProtocolSetup(IpcPortName);
protocol.ChannelSettings["exclusiveAddressUse"] = false;
Nov 11, 2014 at 1:59 AM
Hi,

following your instruction I did set exclusiveAddressUse to false, there's no lucky.
but I found this thread about authorizedGroup. IPC channel to windows service: "Failed to connect to an IPC Port: Access is denied." using authorizedGroup = "Everyone"
I tried setting authorizedGroup on both sides ,
protocol.ChannelSettings["authorizedGroup"] = "Everyone" ;
It does work well now !

thank you so much for your patient !
Marked as answer by yallie on 11/11/2014 at 3:44 AM
Coordinator
Nov 11, 2014 at 11:44 AM
Edited Nov 11, 2014 at 4:43 PM
That's absolutely great! I didn't know anything about this setting.
I think it should be added to both IPC protocol setup classes as a normal property.

Regards,
— Alex

PS. Copied to a work item.
Coordinator
Nov 11, 2014 at 5:58 PM
I found that "Everyone" group name is localizable, so it should work as is on English machines only.
My system's language is Russian, so trying to use "Everyone" group name was throwing exceptions.
Nonetheless I found a way to get the localized version of the group name.

Please download and build the latest sources of Zyan.
Everything should work right out of the box, without touching protocol.ChannelSettings.
AuthorizedGroup is now Everyone by default (or its localized counterpart, if the language is not English).

Please let me know if it works on your system.

Regards,
—Alex
Nov 12, 2014 at 3:07 AM
Edited Nov 12, 2014 at 7:37 AM
Hi, Alex

good news !

I've tested the latest sources of Zyan , now IPC channel works damm well without extra settings.

thank you so much for this amazing framework !

Regards,
Ade
Marked as answer by yallie on 11/12/2014 at 1:51 AM
Coordinator
Nov 12, 2014 at 9:51 AM
Thanks Ade, great to hear that!

Regards,
— Alex
Coordinator
Nov 16, 2014 at 12:13 PM
Hi Ade,

I just published a new Zyan release, v2.6.
This release includes the latest changes to IPC channels,
so you can simply use signed assembly from Nuget package
instead of building Zyan from sources yourself:
https://www.nuget.org/packages/Zyan

If you find this release useful, I'd like to ask you to rate it.
Good rating encourages other codeplex users to have a look at the project:
https://zyan.codeplex.com/releases/view/110163

You mentioned that you use Zyan in a project along with IIS.
Please share a short summary of your project on this forum thread:
http://zyan.codeplex.com/discussions/337472

Thanks for using Zyan!

Regards,
— Alex.