Is there any difference in hosting net.tcp wcf services under Windows 7 and Windows 2008 Server in IIS? - wcf

I have a situation where I can't host a service using net.tcp under windows 7 but it works fine on windows 2008 server. I have enabled WAS, and made the same settings in both windows 7 and windows server but for some reason it doesn't work in windows 7. The error I get on the client side is:
System.ServiceModel.EndpointNotFoundException: The message could not be dispatched because the service at the endpoint address 'net.tcp://localhost:908/TcpTest/MySuperService.svc' is unavailable for the protocol of the address.
Server stack trace:
at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open()
And in the event log I got the following error for the service:
An error occurred while trying to listen for the URL '/LM/W3SVC/9/ROOT/TcpTest'. This worker process will be terminated.
Sender Information: net.tcp
Exception: System.ServiceModel.WasHosting.TcpAppDomainProtocolHandler/24230272
Process Name: System.ServiceModel.CommunicationException: The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service: .
at System.ServiceModel.Channels.SharedConnectionListener.SharedListenerProxy.Register()
at System.ServiceModel.Channels.SharedConnectionListener.SharedListenerProxy.Open(Boolean isReconnecting)
at System.ServiceModel.Channels.SharedConnectionListener.StartListen(Boolean isReconnecting)
at System.ServiceModel.Channels.SharedTcpTransportManager.OnOpenInternal(Int32 queueId, Guid token)
at System.ServiceModel.Activation.HostedTcpTransportManager.Start(Int32 queueId, Guid token, Action messageReceivedCallback)
at System.ServiceModel.WasHosting.TcpAppDomainProtocolHandler.OnStart()
at System.ServiceModel.WasHosting.BaseAppDomainProtocolHandler.StartListenerChannel(IListenerChannelCallback listenerChannelCallback)
Process ID: w3wp
The web.config is exactly the same for the service on both windows 7 and windows 2008. Any clues?

I was having this same problem, in which the exception message ends in
... NetTcpPortSharing service: .
which gives no clue where to go from there.
It turned out that the Net.Tcp Listener Adapter service was pointing to .NET 3 and the Net.TCP Port Sharing Service was pointing to .NET 4
I was able to quickly fix it by running
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ServiceModelReg.exe -r

I guess you've already solved it since...
Was it the case with portsharing was not enabled ?
http://msdn.microsoft.com/en-us/library/aa395195.aspx

It seems like it is working. I have a new computer now and tried it again with not problem at all. So it should work just fine to host net.tcp on Win 7 with IIS7.

Related

RavenDB Unable to boot server on local machine

i keep having the same problem for a few weeks now and i can't seem to figure out what it is.
I recently stared using RavenDB and it was working fine, but after a few days when i come home and want to boot the server on my local machine it just does not want to boot, it gives the following stack trace in the logs:
2019-03-05T18:58:43.0323063Z, 1, Operations, Server, Raven.Server.RavenServer, Failed to create a webhost to redirect HTTP traffic to HTTPS, EXCEPTION: System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransport.BindAsync()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass22_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
at Raven.Server.RavenServer.RedirectsHttpTrafficToHttps() in C:\Builds\RavenDB-Stable-4.1\41010\src\Raven.Server\RavenServer.cs:line 312
Now i am not very familiar with networking but i have no clue why initially it works for a few days and then it just stops working.
Any help would be greatly appreciated.
The most likely reason is that there is something that is already using the port that RavenDB is trying to bind into.
Check things like Get-NetTCPConnection output or netstat to verify that

ADFS 3.0 cannot bind the services endpoint with default configuration

I installed AD FS 3.0 with a default configuration on a server where IIS was already installed. Every time the service is started, it complains about not being able to bind the IP endpoint 0.0.0.0:808.
Here is an excerpt from event log:
Source: AD FS
Event id: 102
Description:
There was an error in enabling endpoints of Federation Service. Fix configuration errors using PowerShell cmdlets and restart the Federation Service.
Additional Data
Exception details:
System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:808. This could happen if there is another application already listening on this endpoint or if you have multiple service endpoints in your service host with the same IP endpoint but with incompatible binding configurations. ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
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.ConnectionAcceptor.StartAccepting()
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.TcpChannelListener`2.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.IdentityServer.ServiceHost.STSService.StartSTSService(ServiceHostManager serviceHostManager, ServiceState serviceState)
AD FS 3.0 has a serious bug when it tries to bind the default services port 1501. It actually ignores the setting and tries to bind on the default net.tcp port 808 by stripping the port away from the URI if it is configured to 1501. To get things worse this binding is hard-coded and therefore port sharing can't be configured for this.
I used this technet article to change the port to 1502 and all seems to work like a charm.
To change the services net.tcp port from 1501 to 1601
Launch PowerShell
Add the AD FS 2.0 PowerShell snap-in:
add-pssnapin microsoft.adfs.powershell
Configure the Services net.tcp port via the Set-ADFSProperties cmdlet:
Set-ADFSProperties -nettcpport 1601
Confirm the change:
Get-ADFSProperties
Restart the AD FS 2.0 service in the Services console

Microsoft Service Bus 1.1 configuration wizard fails - The LDAP server is unavailable

I use the service bus configuration wizard and, while everything seems fine during validation, in the end I get this:
[Error] [20/2/2014 11:07:14 ]: System.Management.Automation.CmdletInvocationException: The server could not be contacted. ---> System.DirectoryServices.AccountManagement.PrincipalServerDownException: The server could not be contacted. ---> System.DirectoryServices.Protocols.LdapException: The LDAP server is unavailable.
at System.DirectoryServices.Protocols.LdapConnection.Connect()
at System.DirectoryServices.Protocols.LdapConnection.SendRequestHelper(DirectoryRequest request, Int32& messageID)
at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request, TimeSpan requestTimeout)
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
--- End of inner exception stack trace ---
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
at System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, ContextOptions options, String userName, String password)
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType)
at System.DirectoryServices.AccountManagement.UserPrincipal.get_Current()
at Microsoft.ServiceBus.Commands.ServiceBusBaseCmdlet.CreateAdminGroup(String adminGroup)
at Microsoft.ServiceBus.Commands.NewSBFarmBase.ProcessRecordImplementation()
at Microsoft.ServiceBus.Commands.ServiceBusBaseCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
--- End of inner exception stack trace ---
at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
at Microsoft.ServiceBus.ConfigWizard.CommandletHelper.InvokePowershell(Command command, Action`3 updateProgress)
at Microsoft.ServiceBus.ConfigWizard.ProgressPageViewModel.CreateSBFarm(FarmCreationModel model)
Ideas anyone?
EDIT:
I have tried disabling my firewall completely, I enabled and started the "SQL Server Browser" service, tested my credentials, and I am completely clueless...
(I also have the SQL Server instance on my local machine, if that matters)
EDIT2:
After trying with another user account (the one I was inserting in the wizard) I got this:
[Error] [21/2/2014 10:24:39 πμ]: System.Management.Automation.CmdletInvocationException: Starting service Service Bus Gateway on machine TURBOX-PC failed: Time out has expired and the operation has not been completed. ---> Microsoft.ServiceBus.Commands.Common.Exceptions.OperationFailedException: Starting service Service Bus Gateway on machine TURBOX-PC failed: Time out has expired and the operation has not been completed. ---> System.ServiceProcess.TimeoutException: Time out has expired and the operation has not been completed.
at System.ServiceProcess.ServiceController.WaitForStatus(ServiceControllerStatus desiredStatus, TimeSpan timeout)
at Microsoft.ServiceBus.Commands.Common.SCMHelper.StartService(String serviceName, Nullable`1 waitTimeout, String hostName)
--- End of inner exception stack trace ---
at Microsoft.ServiceBus.Commands.Common.SCMHelper.StartService(String serviceName, Nullable`1 waitTimeout, String hostName)
at Microsoft.ServiceBus.Commands.ServiceBusConfigHelper.StartSBServices(String hostName, Nullable`1 waitTimeout)
at Microsoft.ServiceBus.Commands.AddSBHost.ProcessRecordImplementation()
--- End of inner exception stack trace ---
at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
at Microsoft.ServiceBus.ConfigWizard.CommandletHelper.InvokePowershell(Command command, Action`3 updateProgress)
at Microsoft.ServiceBus.ConfigWizard.ProgressPageViewModel.AddSBNode(FarmCreationModel model, Boolean isFirstCommand)
EDIT :
Using a different account and different port numbers (the default didn't work) I have managed to configure the SB, but now for some reason it still tries to use the default ports...
Does this thing work on ports other than the default ones?
If you are logged in as a domain user you need contact with the domain controller. This is what is failing for you.
I got this same error when trying to install service bus on my work laptop at home. When back at the office the installation was successful.
Some additional information about system requirements here: https://msdn.microsoft.com/en-us/library/dn441409.aspx

Port being used by another application in WCF

I am facing the problem with WCF self hosting application while trying to run with the following configuration:
<system.serviceModel>
<services>
<service name="statisticsCollectingService">
<endpoint address="net.tcp://localhost:8200/RadioStatistics/"
binding="netTcpBinding"
contract="RadioStatistics.Services.IStatisticsCollectingService" />
<endpoint address="http://localhost:8100/RadioStatistics/"
binding="basicHttpBinding"
contract="RadioStatistics.Services.IStatisticsCollectingService" />
</service>
<service name="biDataExportService">
<endpoint address="net.tcp://localhost:8001/RadioStatistics/"
binding="netTcpBinding"
contract="RadioStatistics.Services.IBIDataExportService" />
</service>
</services>
</system.serviceModel>
The exception occurs as follows:
System.Configuration.ConfigurationErrorsException: Error creating context 'spring.root': The process cannot access the file because it is being used by another process ---> Spring.Objects.Factory.ObjectCreationException: Error creating object with name 'statisticsCollectingServiceHost' defined in 'config [C:\TTL\zer_rel_12_1_main_TTL_C1077\TTL\CommonTools\RadioStatistics\bin\Debug\RadioStatistics.ServerApp.vshost.exe.Config#spring/objects] line 4' : Initialization of object failed : HTTP could not register URL http://+:8000/RadioStatistics/services/ because TCP port 8000 is being used by another application. ---> System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL http://+:8000/RadioStatistics/services/ because TCP port 8000 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.AddAll()
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.TransportChannelListener.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelListener.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.Channels.CommunicationObject.Open()
at Spring.ServiceModel.Activation.ServiceHostFactoryObject.AfterPropertiesSet() in l:\projects\spring-net\trunk\src\Spring\Spring.Services\ServiceModel\Activation\ServiceHostFactoryObject.cs:line 176
at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InvokeInitMethods(Object target, String name, IConfigurableObjectDefinition definition) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractAutowireCapableObjectFactory.cs:line 1264
at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.ConfigureObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractAutowireCapableObjectFactory.cs:line 1860
at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractAutowireCapableObjectFactory.cs:line 884
--- End of inner exception stack trace ---
at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractAutowireCapableObjectFactory.cs:line 901
at Spring.Objects.Factory.Support.AbstractObjectFactory.CreateAndCacheSingletonInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectFactory.cs:line 2097
at Spring.Objects.Factory.Support.AbstractObjectFactory.GetObjectInternal(String name, Type requiredType, Object[] arguments, Boolean suppressConfigure) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectFactory.cs:li
Running a Windows XP SP3 was already trying to do the following:
httpcfg set urlacl /u http://+:8100/RadioStatistics/ /a "D:(A;;GX;;;BU)"
(with I guess all possible variants of general grants and/or users - like DU (for domain users?)
Also trying to add to the IP list
httpcfg set iplisten -i 0.0.0.0:8100
This was after I've found an event in the event log:
Unable to bind to the underlying
transport for 0.0.0.0:8100. The IP
Listen-Only list may contain a
reference to an interface which may
not exist on this machine. The data
field contains the error number.
The worst is that it was already working in the past (before I went on holidays few weeks ago). The machine seems unchanged to me as it was not being touched. But the error drives me crazy. The worst thing is that the error occurs regardless the choosen port.
Of cource it works absolutely fine after the basicHttpBinding is removed.
TIA
Roland
You may have something else listening on the same port. Try running
netstat -o -n -a
to get a list of all the processes and what they are listening for.
I believe this has to do with configuring the service in .NET 3.5 and then changing to .NET 4.0 - the service configuration defaults have changed radically, and now by default many endpoints are created. http://blogs.msdn.com/b/endpoint/archive/2009/06/30/service-configuration-improvements-in-net-4.aspx
#Roland, I know this is a very old post and I have seen you asking this on other sites as well. I have recently had this problem for a very long time. Eventually I have two ways of resolving this.
1) Though this is probably not the recommended way, get local admin permission on the account that runs the window service. This is why when people run VS as admin this problem goes away on their local machine because HTTP by default grants permission to local admin.
2) As you said, use httpcfg on xp/2003 server to configure the url and port number like you did; worth mentioning that "D:(A;;GX;;;LS)" is the correct SDDL that worked for me; I tried others but didn't work. Equally importantly, don't include the service name when configuring just use httpcfg set urlacl -u http://+:portnumber -a D:(A;;GX;;;LS)". And don't configure iplisten with httpcfg as this will most likely prevent IIS running on the server. The error you got from the event log: "Unable to bind to the underlying transport for 0.0.0.0:8100. The IP Listen-Only list may contain a reference to an interface which may not exist on this machine. The data field contains the error number" suggests that IIS is stopped. In fact if you do httpcfg query iplisten you should only see the default ipaddress 0.0.0.0. After configuring the url using httpcfg you need to restart http with net stop http and wait for everything to stop successfully. Then do net start http. If http couldn't stop properly you need to reboot the server after which IIS should be running (if you had deleted any invalid ipaddress). Then start your window service and check with netstat -an | findstr "0.0:yourportnumber" if there is a result then that means your window service is working now.
Just to add, I have followed the instructions on our first dev server and it didn't work initially because 1) I added iplisten and 2) I didn't restart http after configuring the url. 3) I didn't check to make sure iis was running properly.
Hope this helps somehow.
This problem is solved by right clicking on your Visual Studio application icon and selecting "Run as administrator".
Here's an excerpt from the Microsoft official documentation page:
The service must be run with administrator privileges. Because you opened Visual Studio with administrator privileges, when you run GettingStartedHost in Visual Studio, the application is run with administrator privileges as well. As an alternative, you can open a new command prompt as an administrator (select More > >Run as administrator from the shortcut menu) and run GettingStartedHost.exe within it.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/how-to-host-and-run-a-basic-wcf-service
You may need to change the port number as well.

WCF Session problem

I'm new to WCF and have not much idea. By using a sample code I tried WCF through remoting...
It works fine for few min but if i leave the client without accessing the WCF server I get an exception like this....
Exception:Unable to connect to the remote server.
Inner Exception :
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 122.165.27.38:80
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
Stack Trace :
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at TeleMailer.TeleMailer.cbxtmuname_SelectedIndexChanged(Object sender, EventArgs e)
Source :
System
Exception :Server was unable to process request. ---> The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
Inner Exception :
Stack Trace :
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at TeleMailer.Server.Service.get_path()
at TeleMailer.TeleMailer.TeleMailer_Load(Object sender, EventArgs e)
Source :
System.Web.Services
But it's not in faulted state nor it's closed!!!
Actually in my application the client communicates to the server which in turn contacts the WCF and gives him the work to do....
Right now I'm using Cassini as my server. It works great for few min but after nearly ten min it just shows this error message.... but if i restart my Cassini it works properly for few min again and gets the problem....
I cant understand how it goes to faulted state when it's able to connect more clients....
is it because the session has timed out or what? and if session has timed out then from which side from my server or client???
Any Idea plz..........
I've been siting with it for whole day but could not trace out any thing!!!
It may be a timeout problem, related to when you create the wcf proxy object in your client code.
It looks like you create the proxy object when you start the client and then just reuse it. This object maintains a connection to the server, which timesout after 10 min.
A better way to do it would be to create a new proxy object with a using statement, each time you need it.
" if i leave the client without accessing the WCF server I get an exception like "
May be due to inactivityTimeout, so you can increase it, or dispose your client object as soon as possible (try using statement)
you can set the property as follows
<reliableSession ordered="true" inactivityTimeout="00:00:05"
enabled="false" />