I'm trying to use Azure WCF Relays, creating my listener via a ServiceHost instance. It works well, but I can't make it work in both HTTP and HTTPS. I know it seems strange but that's a requirement I have.
Here is my code:
Uri httpUri = ServiceBusEnvironment.CreateServiceUri(Uri.UriSchemeHttp, "MYNAMESPACE", "TEST");
Uri httpsUri = ServiceBusEnvironment.CreateServiceUri(Uri.UriSchemeHttps, "MYNAMESPACE", "TEST");
WebServiceHost sh = new WebServiceHost(typeof(TestAPI), httpsUri, httpUri);
sh.Open();
And here is my conf:
<bindings>
<webHttpRelayBinding>
<binding name="https" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" sendTimeout="00:15:00">
<security mode="Transport" relayClientAuthenticationType="None"/>
</binding>
<binding name="http" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" sendTimeout="00:15:00">
<security mode="None" relayClientAuthenticationType="None"/>
</binding>
</webHttpRelayBinding>
</bindings>
<services>
<service name="TestAPI" behaviorConfiguration="default">
<endpoint name="MobileEndpointHttps" contract="ITestAPI" binding="webHttpRelayBinding" bindingConfiguration="https" behaviorConfiguration="sbTokenProviderTest" address="" />
<endpoint name="MobileEndpoint" contract="ITestAPI" binding="webHttpRelayBinding" bindingConfiguration="http" behaviorConfiguration="sbTokenProviderTest" address="" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="sbTokenProviderTest">
<webHttp/>
<serviceRegistrySettings discoveryMode="Public" />
<transportClientEndpointBehavior>
<tokenProvider>
<sharedAccessSignature keyName="RootManageSharedAccessKey" key="MYKEY"/>
</tokenProvider>
</transportClientEndpointBehavior>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="default">
<serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="false"/>
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
The httpGetEnabled & httpsGetEnabled seems not required to make it work alone, so I disabled it to avoid the netsh warning.
With this config, I get the following error:
System.InvalidOperationException: The ChannelDispatcher at 'sb://mynamespace.servicebus.windows.net/TEST/' with contract(s) '"ITestAPI"' is unable to open its IChannelListener. ---> System.InvalidOperationException: A registration already exists for Uri 'sb://mynamespace.servicebus.windows.net/TEST/'.
Is it at least possible ? Need your help :(