Wcf AddressAlreadyInUseException

I already looked through these messages: wcf System.ServiceModel.AddressAlreadyInUseException , Windows service hosted WCF on top of HTTPS , Getting an AddressAlreadyInUseException after upgrading to .NET 4.5 , none of them solves my problem. I have several wcf services in .net 4.5. They are all in the same address, I get this exception in the WCF service host:

System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL https://+:443/mafawcf01/ServicioAddin.svc/ because TCP port 443 is being used by another application. ---> System.Net.HttpListenerException: The process cannot access the file because it is being used by another process at System.Net.HttpListener.AddAllPrefixes() at System.Net.HttpListener.Start() at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() --- End of inner exception stack trace --- at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener) at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback) at System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.DatagramChannelDemuxer`2.OnOuterListenerOpen(ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout) at System.ServiceModel.Channels.SingletonChannelListener`3.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout) at System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Security.SecuritySessionSecurityTokenAuthenticator.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Security.SecurityUtils.OpenTokenAuthenticatorIfRequired(SecurityTokenAuthenticator tokenAuthenticator, TimeSpan timeout) at System.ServiceModel.Security.SecuritySessionServerSettings.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout) at System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.DelegatingChannelListener`1.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info) System.Net.HttpListenerException (0x80004005): The process cannot access the file because it is being used by another process at System.Net.HttpListener.AddAllPrefixes() at System.Net.HttpListener.Start() at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() 

Here is my app.congif:

  <host> <baseAddresses> <add baseAddress="https://localhost:443/mafawcf01/ServicioAddin.svc"/> </baseAddresses> </host> </service> <service name="mafawcf01.ServicioPing" behaviorConfiguration="mafawcf01.ServicioPingBehavior"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="secureHttpBinding" contract="mafawcf01.IServicioPing"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="https://localhost:443/mafawcf01/ServicioPing.svc" /> </baseAddresses> </host> </service> <service behaviorConfiguration="mafawcf01.Service1Behavior" name="mafawcf01.ServicioCargue"> <endpoint address="https://localhost:443/MafaWCF01/ServicioCargue.svc" binding="customBinding" bindingConfiguration="myCustomHttpBinding" contract="mafawcf01.IServicioCargue" /> <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="https://localhost:443/MafaWCF01/ServicioCargue/" /> </baseAddresses> </host> </service> <service behaviorConfiguration="mafawcf01.Service1Behavior" name="mafawcf01.ServicioValidacionMultiple"> <endpoint address="https://localhost:443/MafaWCF01/ServicioValidacionMultiple.svc" binding="customBinding" bindingConfiguration="transporteSeguro" contract="mafawcf01.IServicioValidacionMultiple" /> <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="https://localhost:443/MafaWCF01/ServicioValidacionMultiple/" /> </baseAddresses> </host> 

I already have a port reserved with this command:

 netsh http add urlacl url=https://+:443/MafaWCF01 

And also the certificate associated with the port:

 netsh http add sslcert ipport=0.0.0.0:443 certhash={some cert hash} appid={some appid} 

Do you need more information?

+6
source share
3 answers

I found that a WCF application (or rather, http.sys ) can hold the URL for a while after closing it. If you try to restart it immediately, you may get a scary AddressAlreadyInUseException because the previous application instance somehow holds it. I found that if I wait a few minutes and try again, it might work.

+5
source

In case this helps anyone. I had the same problem when trying to host the wcf service in a console application. What I did was open. Wcf service data library property (Alt + Enter or right click-> Property), then go to the "WCF Settings" tab in the "Properties" window and turn off "Start WCF service host when debugging another project in the same solution." Then the problem is fixed.

+4
source

I had the same problem.
I could not find any other application listening on this port, had no conflict, but this error message did not go away.
this happened immediately after the service crashed, and since then I have not been able to return it again.
In any case, after rebooting the PC everything worked. Oh good..

0
source

All Articles