Skip to content

NetTcpBinding, Streamed transfer and TransportWithMessageCredential incompatible with TelemetryEndpointBehavior #1369

@MikkelPorse

Description

@MikkelPorse

Issue with OpenTelemetry.Instrumentation.Wcf

OpenTelemetry.Instrumentation.Wcf 1.0.0-rc.12

net48

Is this a feature request or a bug?

  • Feature Request
  • Bug

What is the expected behavior?

Creation of a Channel - and not an InvalidOperationException.

What is the actual behavior?

Repro project

When attempting to create ChannelFactory over a NetTcp-binding using the TelemetryEndpointBehavior and a specific combination of transferMode and security, an exception thrown at me:

Unhandled Exception: System.InvalidOperationException: Binding 'NetTcpBinding' doesn't support creating any channel types. This often indicates that the BindingElements in a CustomBinding have been stacked incorrectly or in the wrong order. A Transport is required at the bottom of the stack. The recommended order for BindingElements is: TransactionFlow, ReliableSession, Security, CompositeDuplex, OneWay, StreamSecurity, MessageEncoding, Transport.
   at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose)
   at System.ServiceModel.ChannelFactory.CreateFactory()
   at System.ServiceModel.ChannelFactory.OnOpening()
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ChannelFactory.EnsureOpened()
   at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.ChannelFactory`1.CreateChannel()

Additional Context

The exception is a consequence of using securityMode = TransportWithMessageCredential , transferMode = Streamed,
and the code at TelemetryEndpointBehavior.cs.84:

newBinding.Elements.Insert(0, new TelemetryBindingElement());

The problem is, that inserting the TelementryBindingElement at the top of the stack messes something up. Buffered mode is ok and so is Streamed with any securityMode other than TransportWithMessageCredential. What i found, was inserting at index = 2, 3 and 4 works, which pushes the BindingElement in after the SecurityBindingElement - maybe that's the key?!

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp:instrumentation.wcfThings related to OpenTelemetry.Instrumentation.Wcf

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions