.netwcfwcf-bindingduplex-channelprotocolexception

WCF server with .net 4.7 and client with .net 6.0 - protocol error


I currently try to extend a WCF windows only program to make it viable on Linux. Therefore, I need to port the WCF backend communication to .net 6.0. I establish a server connection like this:

public static IService Connect(ServerCredential credentials, IServiceCallback callback)
{
    var binding = new NetHttpBinding(BasicHttpSecurityMode.None, true)
    {
        WebSocketSettings =
        {
            TransportUsage = WebSocketTransportUsage.Always
        },
        ReaderQuotas =
        {
            MaxDepth = int.MaxValue,
            MaxArrayLength = int.MaxValue,
            MaxBytesPerRead = int.MaxValue
        },
        MaxReceivedMessageSize = 2147483647L,
        SendTimeout = TimeSpan.FromMinutes(20.0),
        ReceiveTimeout = TimeSpan.FromSeconds(2.0),
        OpenTimeout = TimeSpan.FromSeconds(2.0),
        CloseTimeout = TimeSpan.FromSeconds(2.0)
    };

    var instanceContext = new InstanceContext(callback);

    var factory = new DuplexChannelFactory<IService>(
        instanceContext,
        binding,
        new EndpointAddress(credentials.Domain));

    var channel = factory.CreateChannel();

    channel.Authenticate(credentials.User, credentials.Password); // <- error

    return channel;
}

The error message:

System.ServiceModel.ProtocolException: 'The remote endpoint requested an address for acknowledgements that is not the same as the address for application messages. The channel could not be opened because this is not supported.

I tried the same code in a .net 4.7 application and it works. (of course with other using namespaces and other syntax)

My question is now. Is it even possible to accomplish a server connection with a client, if the WCF client is on .net 6 and the server is on .net 4.7.

And yes. I know. WCF is depriecated but it is not my idea to develop in it.. Thank you for your time! :)


Solution

  • wcf cannot be used directly in.NET 6.0. You need to migrate wcf code to CoreWCF or consider using gRPC.