Windows 11 VS2019 vb.net. The WCF service listens on the specified port when hosted in a console app but fails to listen when hosted from within a Windows service. Verified by executing "netstat -aon". I assume the problem is with my deployment of the windows service since everything works great when hosted in the console app. A client can connect, etc. All of this is being performed on the same computer so no firewall issues. But I did turn off the firewall to test. I also tried the service installation on a different computer with the same results. Since this my first post, I'll try to include some code to demonstrate my config.
<system.serviceModel>
<services>
<service behaviorConfiguration="WcfHomeCamInterface.Service1Behavior"
name="WcfHomeCamInterface.wcfHomeCamService">
<endpoint address="" binding="netTcpBinding" contract="WcfHomeCamInterface.IHomeCamService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9000" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="tcp_Unsecured"
transferMode="Buffered"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<security mode="None"/>
<readerQuotas maxArrayLength="2147483647" />
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="WcfHomeCamInterface.Service1Behavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="False"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
I've tried several different config file configurations with the same result. I've also tried different accounts from within the ProjectInstaller as well. However, the rest of the Windows service runs correctly - connects to the Sqllite database and executes all of the other subroutines. Do certain other windows services need to be running?? Any ideas would be appreciated, Thanks.
CodePudding user response:
Check whether the port is occupied, and then run the following command:
netsh http add urlacl url=http:// :8080/ user="NETWORK SERVICE"
If something goes wrong, you can also delete it with this command:
netsh http delete urlacl url=http:// :8080/
As far as I know, debugging is a cumbersome and lengthy process, and I hope this method can help you.
CodePudding user response:
I did get this to work by re-creating the WCF and Windows service from scratch. Before, I had just copied and pasted code from a project that I had created a few years ago. I'm not sure what was causing the original problem, but it now works with the service on one computer and the client on another in the same subnet. Thanks in advance....
Here is the working config file on the server:
<system.serviceModel>
<services>
<service name="WcfCamLibrary.CamService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="tcp_Unsecured"
contract="WcfCamLibrary.ICamService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="tcp_Unsecured"
transferMode="Buffered"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<security mode="None" />
<readerQuotas maxArrayLength="2147483647" />
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>