wcf dual channel error - c#

I have a wcf service that users can chat trough it.
when I test it in local IIS it works, but when publish it in external server, and call a method, it throws:
Security negotiation failed because the remote party did not send back
a reply in a timely manner. This may be because the underlying
transport connection was aborted.
webconfig.conf
....
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="bind" textEncoding="utf-8">
<security mode="None" />
</binding>
</wsDualHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="svcbh">
<serviceMetadata httpGetEnabled="False" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="QasedakServer.QasedakAPI" behaviorConfiguration="svcbh">
<host>
<baseAddresses>
<add baseAddress="http://www.mywebsite.com/" />
</baseAddresses>
</host>
<endpoint name="duplexendpoint" address="" binding="wsDualHttpBinding" contract="QasedakServer.IQasedakAPI" bindingConfiguration="bind" />
<endpoint name="MetaDataTcpEndpoint" address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
....
my program uses dual channel mode connection.
plz help me.

Related

Windows Service hosting WCF service can only be accessed by my domain user

I had developed a windows service that hosts a WCF service. The service is installed on a server and the idea is to process some files on the local network (domain). Also, the service is executing as my domain user.
the configuration of the service is this:
<system.serviceModel>
<services>
<service name="Zeus.My.Upload.Service.MyHostedService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:1089/Domain/Service"/>
</baseAddresses>
</host>
<endpoint address="http://localhost:1089/Domain/Service/Uploader" binding="basicHttpBinding" contract="Zeus.My.Upload.Contract.IHostedService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="4294967296" transferMode="Streamed" sendTimeout="01:00:00" messageEncoding="Mtom">
<security mode="None">
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
The issue with this configuration is that only my user is able to access and use this service. Other users of domain cannot even access to the URL.
How can I solve this issue?

Can't access WCF service through https

I setup a WCF application to be hosted by a Windows service. I got this to work correctly and I can navigate to it by going to http://127.0.0.1:1214. Here is the configuration:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="NetworkPrintClient.PrintWebService" behaviorConfiguration="PrintServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://127.0.0.1:1214/"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="NetworkPrintClient.IPrintWebService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PrintServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Now I'd like to make this accessible at https://127.0.0.1:1214. After reading several articles about doing this, I end up with the config below. But, I can't browse to the application anymore. I just get a "This site can't be reached" error in Chrome.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="NetworkPrintClient.PrintWebService" behaviorConfiguration="PrintServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://127.0.0.1:1214/"/>
</baseAddresses>
</host>
<endpoint address="" binding="webHttpBinding" contract="NetworkPrintClient.IPrintWebService" behaviorConfiguration="HttpBehavior" bindingConfiguration="PrintServiceHttpsBinding"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PrintServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="HttpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="PrintServiceHttpsBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<protocolMapping>
<add binding="webHttpBinding" scheme="https"/>
</protocolMapping>
</system.serviceModel>
</configuration>
The article I used to get this far is here. I did the part at the bottom about making the certificate and mapping it to my IP and port. I also tried to get this to work with "localhost" and my actual IP address. Can anyone see what I'm doing wrong?
You must to create a certificate selfhosted to localhost, you can use this command line in powersheel
New-SelfSignedCertificate -DnsName "localhost", "localhost" -CertStoreLocation "cert:\LocalMachine\My" when you execute is gonna generate the thumbprint of certificate keep to associate to the port something like this "B80BE75765AA5739EAC63AAF67C32E5A3625FF19"
in window type "certificates" and click manage computer certificates and copy the certificate from personal\certificates to trusted root certification authorities\certificates
associate the certificate hash (thumbprint to the port) - netsh http add sslcert ipport=0.0.0.0:{0} certhash={1} appid={2} certstore=MY 0 - port - 1 - (the thumbprint generated by the certificate) 2 - {555b2e5f-4877-459b-bff2-60bb25898455} (GUID)

How to configure URL of a WCF Service referenced within another WCF Service Library

This is hard to explain so please ask me to clarify anything that is unclear.
I have 3 WCF web service libraries and 3 host applications I will call them Service1, Service2 and Service3. Service2 is in the same solution but is not relevant to this question at the moment.
Service1 references Service3 Host Application. Once it is compiled I cannot see any way to configure the URL for Service3 in Service1.
I would like it to be in the config for Service1 Host Application. Is this possible? I can't believe this is hard coded in the DLL?
Service1 Library App.Config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Service3Data" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://MyHost/gws/GService3.svc/gwd"
binding="basicHttpBinding" bindingConfiguration="Service3Data"
contract="GServices3.IGws" name="Service3Data" />
</client>
<services>
<service name="MyNameSpace.Business.WebServices.Service1">
<endpoint address="" binding="basicHttpBinding" contract="MyNameSpace.Business.WebServices.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/MyNameSpace.Business.WebServices/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
Service1 Host Application Web.Config (and where I need to configure the URL for Service3):
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Service1Binding" openTimeout="00:10:00" maxBufferPoolSize="2147483646"
maxBufferSize="2147483646" maxReceivedMessageSize="2147483646">
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646"
maxArrayLength="2147483646" maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="MyNameSpace.Business.WebServices.Service1">
<endpoint address="bwd" binding="basicHttpBinding" bindingConfiguration="Service1Binding"
name="BWData" contract="MyNameSpace.Business.WebServices.IService1" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
When you create a proxy for a WCF service, you can always add a <system.serviceModel> section to the main assembly and configure all the settings in there (including the URL of the service you creates a proxy for).
If you add your proxy in a library assembly, you can still add <system.serviceModel> to the main (executable/web host/etc.) assembly.
You need to copy the <client> section from the library config to the host application config (together with its binding and possibly other elements).

Unable to call through https request

I'm using the website which contain .svc file and hosted on https as rest api. My question is:
My website has SVCUTIL.exe is https://XXXXXXX but when I call it with https request it fails but working fine with http request.And I don’t want use SSL certificates
Thanks
This is my webconfig settings:
<serviceBehaviors>
<behavior name="Mybehaviour">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="Mybehaviour" name="PBUIService">
<endpoint address="https://XXXXXXXXXXXXXXX" behaviorConfiguration="PBBehaviour" binding="webHttpBinding" bindingConfiguration="wsHttpBindingSettings" contract="PBUIService">
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
I've added the following lines to make it work with https:
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>

I couldn't properly publish duplex wcf service

I am trying to publish my duplex wcf service on a server with no success, I am able to publish it on local IIS, but when I publish it to server its address become net.tcp://win-rhkt30stjd7/Broadcastor/BroadcasterService.svc. As you would agree such address is not useful at all while creating the service reference on client. I tried to publish it as WCF application project, and service library project but both is giving the same result. Probably something is missing from my Web.config file but I don't know what it is. Please help me out here. Below is my Web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" />
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<services>
<service name="BroadcastorServiceApp.BroadcastorService">
<endpoint binding="netTcpBinding" contract="BroadcastorServiceApp.IBroadcastorService">
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding>
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
I dont see any address part in your NET TCP endpoint
1 : Add a base address as below :
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8088" />
</baseAddresses>
</host>
2 : add an address parameter to your net tcp endpoint as :
<endpoint address = "tcpEndPoint"
binding="netTcpBinding"
contract="BroadcastorServiceApp.IBroadcastorService"></endpoint>
3 : Alse give a behavior name as :
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
And add it to the service like :
<service name="BroadcastorServiceApp.BroadcastorService" behaviorConfiguration="ServiceBehavior">
<endpoint binding="netTcpBinding" contract="BroadcastorServiceApp.IBroadcastorService"></endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>

Categories

Resources