Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Remoting / January 2004

Tip: Looking for answers? Try searching our database.

Singleton or SingleCall SAO Socket problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Orlin Popov - 29 Jan 2004 02:32 GMT
Hi!!

I have a very strange problem.

I have a pair of client and server. Server exposes just one object (Server
activated object) and for the problem I have it does not matter whether it
is a SingleCall  or Singleton.

I use standard TCP channel with binary formatters. On the server side I
register the channel with
RemotingConfiguration.RegisterWellKnownServiceType.
On the client side I use Activator.GetObject to obtain the remote object
reference.

After that I use and endless loop to call the server object.
It does not matter whether client and server are on the same machine or not.
It also does not matter if the server activation type is SingelCall or
Singleton. Every now and then (usually after 3 or 4 thousand calls) I get an
exception on the client side :

System.Net.Sockets.SocketException: Only one usage of each socket address
(protocol/network address/port) is normally permitted.

Server stack trace:
  at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
  at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket()
  at System.Runtime.Remoting.Channels.SocketCache.GetSocket(String
machineAndPort)

That is strange because I am not trying to start a second copy of the server
or anything like that. The exception is always on the client side.

Why is this happening?

Please let me know if there is some explanation for this.

Thanks a lot.

Orlin
Sunny - 30 Jan 2004 16:58 GMT
Hi Orline,

most probably you are using TcpClientChannel(0) at client side to get a
free tcp port for callbacks. There is a known problem that the channels
are closed a little bit late (1-10 secs) after the Socket.Close is
invoked. So basically you are running out of free sockets.

Hope that helps
Sunny

P.S. I nazdrave :)

> Hi!!
>
[quoted text clipped - 35 lines]
>
> Orlin
Allen Anderson - 31 Jan 2004 06:17 GMT
Sunny has a good point about the socket objects.  If you take a look
at netstat -a -n from the dos prompt while this is happening you might
see a very large number of sockets popping up.

the solution for this isn't so much how to get more sockets rolling,
but rather to maybe think about the design a bit.  Does it need to be
Singlecall when your just calling the same server over and over from
the same client?  You might be better off with a CAO or SAO Singleton.

Allen Anderson
http://www.glacialcomponents.com
mailto: allen@put my website url here.com

>Hi!!
>
[quoted text clipped - 35 lines]
>
>Orlin
Orlin Popov - 31 Jan 2004 13:40 GMT
Hi Allen,

Thanks for your comment. It has been very helpful. Actually SAO singleton
shows exactly the same problem.

You are right. Netstat -a shows muliple sockets some in established state,
some in time-wait state. After they reach some limit program starts to
exhibit erratic behavior.

Actually this behavior with TCP channel is triggered when I use my own sink
between formatter and transport, both on client and server side. If I remove
that sink the TCP channel works fine(no multiple sockets generated). My
sinks exchange some out-of-band data in headers and modify streams a little.

I believe this is something with the TCP channel. If I switch to HTTP
channel everything is OK even with my sinks - only one pair of sockets is
crated and it is reused with every call.

What I need to understand is how a new sink can trigger such a wierd
behavior in the channel and Remoting when TCP channel is used so I can
understand what I am doing wrong. I have seen similar sinks working fine. In
theory a socket should be created for each thread that calls remote objects.
In my case I have just one thread that is doing repeated calls.

Thanks,

Orlin

> Sunny has a good point about the socket objects.  If you take a look
> at netstat -a -n from the dos prompt while this is happening you might
[quoted text clipped - 48 lines]
> >
> >Orlin

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.