Login  
Search All Forums
Dart Home | PowerTCP Sockets for .NET | Custom Development Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums   
AuthorForum: PowerTCP Sockets for .NET (Secure and Standard)
Topic: Listener connections accept velocity slow
theincrediblepeep

From: Dallas, TX USA
Posts: 11
Member Since: 07/07/06
posted February 21, 2008 2:17 PM

I have a PowerTCP application that answers connections from one host and establishes a connection to another host, so that it can perform inline accounting and pass-though between the two sockets.

For some reason though, the app can only answer connections at a rate of 30 new calls per minute. So when 200 connections come in all at once, they sit in a queue and the sockets are opened over the course of 7 minutes. Processor utilization remains zero, no disk access or burden on the machine at all, and at this point the app has no responsibilities but to answer the call, establish the high-side connection, and satisfy pass-through. My code does not invoke deliberate delay, everything is event driven. I trace through the call process, and everything from the listener.Connection event coming in to the client.ConnectedChangedEx showing connection showing both sockets up occurs in the same millisecond, so I assume the connection events themselves are in a delayed queue in the PowerTCP API, a delay that is almost always 2.016 seconds between one call accept and the next (except for the distance between the first and second connections which can occur right away).

The problem occurs on VB .NET 2005 and SSL Sockets 1.0.9, but I've had the problem since I bought Standard Sockets 1.0.3 under VB .NET 2003. I have written listeners that don't open client-per-server sockets and they did not have the velocity problem. 

Has anyone else had this issue? Can the problem be eliminated? Any ideas?
Amit

From: Rome, NY USA
Posts: 315
Member Since: 03/15/06
posted February 21, 2008 5:00 PM

Hello

I would suggest you to please set MaxThreads property to a higher value to resolve this issue

Do let me know if you require further assistance/clarifications.

Best Regards,
Amit

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

theincrediblepeep

From: Dallas, TX USA
Posts: 11
Member Since: 07/07/06
posted February 22, 2008 12:57 PM

Thank you for the information. Actually I had already set MaxThreadCount value to 1000, but the problem still remains.
theincrediblepeep

From: Dallas, TX USA
Posts: 11
Member Since: 07/07/06
posted February 22, 2008 4:08 PM

As a clarification, I have tried both

System.Threading.ThreadPool.SetMaxThreads(1000, 1000)

and

listener.MaxThreads = 300

Neither helps the connection answering velocity issue.

However, new information is that the problem seems to be directly related to setting AutoReceive to True. Is it possible that setting AutoReceive to true on one socket can mutex incoming connections on a listener for 2 seconds? How to get past this issue?
Amit

From: Rome, NY USA
Posts: 315
Member Since: 03/15/06
posted February 25, 2008 2:05 PM

Hello,

I tried a lot however was not able to replicate the said issue. I tried running Echo Server sample and then connected as many clients however there was no delay in the connection.
I would suggest you to please try using the same sample and see if you can replicate this issue.
Also, what happens if you set “AutoReceive” to false?
If this does not helps, then please provide us a small client and server sample so that we can check this issue further at our end. You may send the required information to support@dart.com.

Any further information to isolate the issue would be highly appreciated.

Best Regards,
Amit

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

theincrediblepeep

From: Dallas, TX USA
Posts: 11
Member Since: 07/07/06
posted February 26, 2008 6:57 PM

First of all, thank you so much for your diligent assistance. This is a problem with the PowerTCP libraries that I have been troubleshooting for a few years now and haven't figured out. The interface I'm writing was scheduled to begin processing 15,000 transactions/day this morning, so I had to write a substitute for the PowerTCP Tcp and Server classes through regular .NET sockets in the interim. I would still like to resolve the problem with the Dart libraries.

When setting AutoReceive to false, without a data receive handler, the problem goes away, and I can receive new connections at very high velocity. As soon as I apply a BeginReceive() to the sockets, whether it is immediately upon establishing connection or in a Timer about 100 milliseconds later, the problem returns, and subsequent pending connections are in delay 2 seconds per connection. The only thing I can guess is that there is a deliberate 2-second synchronous operation (or two 1-second operations) on receiving data in the Dart Tcp class that inhibits raising the Connected event on the Server class. When I do it directly through .NET sockets, I never encounter the issue.

I tried to tweak the EchoServer application, but I was not able to duplicate the problem using it either. When I have time at a later date, I will put together a simulator which is able to duplicate the problem so that I may submit it to the Dart support email.
Mike Baldwin (Admin)



From: Rome, NY USA
Posts: 114
Member Since: 04/11/00

Extra Support Options
Custom Application Development

posted February 26, 2008 9:22 PM

Hello,

I'm the developer of the Server component you've been using. May I summarize the techniques I think you are using (please correct me if I'm wrong), and suggest an alternative approach?

1. You are using the Server.Listen() method to accept connections. Is there any encryption involved?
2. When the Connection Event is raised, you set the AutoReceive property to true and make a 2nd connection to another server. Also, are you using the SynchronizingObject property, and are you using any timers?
3. When the EndReceive Event is raised, you get the data and send it through to your second connection.
4. Do you also use the AutoReceive property on your 2nd connection so as to send data to the original server?
5. Now, you can only process a connection every 2 seconds. Have I got the picture?

Internally, our code blocks while it waits to accept each connection on a dedicated worker thread. Once accepted, the Connection Event is raised (either on the worker thread, or the UI thread if the Synchronizing property is being used). Before the Connection Event is raised, we spawn another worker thread to accept the next connection.

First, ensure the SynchronizingObject is set to null, because it is only necessary if you are updating the UI, and the message processing involved in performing the thread context change could be part of the problem.

Second, loop inside your Connection Event handler doing blocking Receive() calls and sending any data on (if your data communications model allows this kind of half-duplex operation). Don't perform any asynchronous calls unless you have to. This will minimize your thread usage, which could be a cause.

Third, make sure your DoEvents property is false.

Please let me know how you make out. Good luck!
theincrediblepeep

From: Dallas, TX USA
Posts: 11
Member Since: 07/07/06
posted February 28, 2008 11:09 AM

1. Correct, I am using Server.Listen. I am not using encryption on this product, but another product I've written uses SSL.
2. I set AutoReceive to True on the answering socket and the originating socket at the same time. I do not use SynchronizingObject, and I am not using any timers. I mainly used the events that already exist in the API.
3 & 4. Correct, EndReceive on answering socket issues a Send call to originating socket, and vice versa.
5. Correct.

Also, there isn't really any UI; my apps are predominantly service applications. Do you suggest that I should not have the answering socket and the originating socket both in Receive state at the same time? Our host handles various protocols that may become unreliable in a half-duplex sense, and since some of them are financial transactions, we cannot have a message unattended to if it happens to occur off-duplex.

One thing I have not done was to make a receive loop. Since there were already events built into PowerTCP, I used them instead.

I will try your suggestions and follow up later on. Mike and Amit, thank you very much for all your tremendous help.

Cheers,

Geoff
theincrediblepeep

From: Dallas, TX USA
Posts: 11
Member Since: 07/07/06
posted January 5, 2009 12:52 PM

After a rewrite, the suggestion to disable AutoReceive and use receive loops in their own threads works well to resolve the connect event backup problem. Thank you all for your assistance.
Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX