I am encountering a communication exception in my windows service looking to communicate with a client laptop sitting next to it.
Service cannot be started. System.ServiceModel.CommunicationException: A TCP error (10049: The requested address is not valid in its context) occurred while listening on IP Endpoint=192.168.xx.xx:8080. ---> System.Net.Sockets.SocketException: The requested address is not valid in its context at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Bind(EndPoint localEP) at System.ServiceModel.Channels.SocketConnectionListener.Listen() --- End of inner exception stack trace --- at System.ServiceModel.Channels.SocketConnectionListener.Listen() at System.ServiceModel.Channels.BufferedConnectionListener.Listen() at System.ServiceModel.Channels.ExclusiveTcpTransportManager.OnOpen() at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener) at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback) at System.ServiceModel.Channels.Con...
Here is the app config file code:
here is the service codeCode:<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.diagnostics> <sources> <!-- This section defines the logging configuration for My.Application.Log --> <source name="DefaultSource" switchName="DefaultSwitch"> <listeners> <add name="FileLog"/> <!-- Uncomment the below section to write to the Application Event Log --> <!--<add name="EventLog"/>--> </listeners> </source> </sources> <switches> <add name="DefaultSwitch" value="Information" /> </switches> <sharedListeners> <add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/> <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log --> <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> --> </sharedListeners> </system.diagnostics> <system.serviceModel> <bindings /> <client /> <behaviors> <serviceBehaviors> <behavior name="MetaBehavior"> <serviceMetadata httpGetEnabled="false" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="MetaBehavior" name="WcfJobsLibrary.Jobs"> <clear /> <endpoint address="mex" binding="mexTcpBinding" name="mexEndpoint" contract="IMetadataExchange" listenUriMode="Explicit"> <identity> <dns value="localhost" /> <certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" /> </identity> </endpoint> <endpoint address="" binding="netTcpBinding" bindingConfiguration="" name="NetTcpBindingEndpoint" contract="WcfJobsLibrary.IJobs"> <identity> <dns value="localhost" /> </identity> </endpoint> <host> <baseAddresses> <add baseAddress="net.tcp://192.168.xx.xx:8080/DeployService" /> </baseAddresses> </host> </service> </services> </system.serviceModel> </configuration>
Code:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.ServiceModel; namespace ABCService { public partial class Service1 : ServiceBase { ServiceHost sHost; public Service1() { InitializeComponent(); } protected override void OnStart(string[] args) { sHost = new ServiceHost(typeof(WcfJobsLibrary.Jobs)); sHost.Open(); } protected override void OnStop() { sHost.Close(); } } }
the client app config here:
I should note that I was getting a failure in the service itself that it would abrupt start and stop automatically due to the exception thrown above which I pulled from the event viewer.. perhaps a try catch trapping the communication exception but beyond that I am wondering how a service that was working just fine a moment ago has these issues ?Code:<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <bindings> <netTcpBinding> <binding name="NetTcpBinding_IJobs" closeTimeout="00:08:00" openTimeout="00:08:00" receiveTimeout="00:15:00" sendTimeout="00:08:00" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:20:00" enabled="false" /> <security mode="Message"> <transport clientCredentialType="Windows" /> <message clientCredentialType="Windows" algorithmSuite="Default" /> </security> </binding> </netTcpBinding> </bindings> <client> <endpoint address="net.tcp://192.168.xx.xx:8080/DeployJobsService" binding="netTcpBinding" contract="JobsService.IJobs" name="netTcpBinding_IJobs"> </endpoint> </client> </system.serviceModel> </configuration>![]()


Reply With Quote