gustierng
asked on
close connection to server (.net remoting)
How do I close a client connection to a server so that others can use it?
This is using .net remoting, so the ChannelServices.RegisterCh annel to setup the channel and Activator.GetObject used to create a connection to the shared port.
Thank you
This is using .net remoting, so the ChannelServices.RegisterCh
Thank you
this question is similar to https://www.experts-exchange.com/questions/24158999/close-connection-to-server-net-remoting.html
ASKER
yes. nothing related to databases. So does unregistering a channel effectively close the connection by making the port available to other users?
in remoting the port is not used by one connection so there is no point of thinking that once one client is accessing a remoting object other objects cannot access them
secondly you might want to limit the lifetime of the objects created on the server to make optimal use of memoru
and when objects go out of scope the memory as well as connection will be disposed by the garbage collector so you dont have to code an extra step of unregistering the ports
secondly you might want to limit the lifetime of the objects created on the server to make optimal use of memoru
and when objects go out of scope the memory as well as connection will be disposed by the garbage collector so you dont have to code an extra step of unregistering the ports
ASKER
My main problem at the moment is a RemotingException
https://www.experts-exchange.com/questions/24175257/RemotingException.html
https://www.experts-exchange.com/questions/24175257/RemotingException.html
ASKER
Hi
I followed your advice but now I am getting a SocketException:
I start up the server which is updated in realtime on a single port. Users read data on a second port. The first time I run the client it works fine. If I close the app and run the client again I get:
SocketException:
No connection could be made because the target machine actively refused it
I have not even got to the stage of testing multiple users over this port. I am using a singleton, tcp.
I followed your advice but now I am getting a SocketException:
I start up the server which is updated in realtime on a single port. Users read data on a second port. The first time I run the client it works fine. If I close the app and run the client again I get:
SocketException:
No connection could be made because the target machine actively refused it
I have not even got to the stage of testing multiple users over this port. I am using a singleton, tcp.
first time the remoting channel is registered correctly and everything runs correctly
but when you run the client second time the previous channel/port to which the registered does not allow you to register it again
you will have to find a way to deregister the port and then regiester it again
but when you run the client second time the previous channel/port to which the registered does not allow you to register it again
you will have to find a way to deregister the port and then regiester it again
ASKER
that's a good idea, i'll try bthat and let you know.
What if other users are using that port?
What if other users are using that port?
actually its not that port
you dont close the port its the channel that you register on the client machine
port/socket on the server is not affected
you dont close the port its the channel that you register on the client machine
port/socket on the server is not affected
ASKER
ok, so is there a way to refer to a channel by port rather than name?
TcpChannel tcpChannel;
tcpChannel = (TcpChannel)ChannelService s.GetChann el(theChan nelName)
if (tcpChannel!= null)
{
ChannelServices.Unregister Channel(tc pChannel);
}
Or, is this the way it iss done?
TcpChannel tcpChannel;
tcpChannel = (TcpChannel)ChannelService
if (tcpChannel!= null)
{
ChannelServices.Unregister
}
Or, is this the way it iss done?
havent used this in .net 20 or above so cannot say this
sorry
sorry
ASKER
how do you close the channel?
ASKER
that is the same way I have posted above. You need to check the channel exists
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this connection is not the same as sql connection
and secondly when the connection means the clinet object goes out of scope or has completed its processing it just releases its memory
are you getting any kinds of errors due to this on .net remoting