4

I have trouble with Delphi XE2 app. Sometimes WinInet call to ASMX service blocks and never returns - user must terminate process from task manager to close app. To connect to ASMX service app uses service generated by WSDLImp tool.

During its work, app makes a lot of calls to web service (~1000-2000). And at some moment (last time it was 782 request item, first time it was near the end) app freezes. After some digging, logging I find out that app blocks on

WinInetResult := HttpSendRequest(Request, nil, 0, DatStr.Bytes, DatStr.Size);

In Soap.SOAPHTTPTrans unit

First guess was it is some server-side problem – server hangs on request processing. But on trials server was processing requests from other clients, while target one was blocked. And, when you use Fiddler to debug http traffic from app everything works as expected, no locks. Also, WinInet’s SendTimeout, ReceiveTimeout, ConnectTimeout has no effect – there are no timeout errors. One more point, app blocks not on specific method call, but on different ones.

After googling, I find out that HttpSendRequest can block on max parallel connections exceeded. But there are no parallel execution in app – each action is performed in main GUI thread.

My next try was to use Indy for HTTP communication instead of WinInet. And with Indy, app does its work as it should, no locks. But downside is performance degradation – app’s work takes two times longer with Indy.

This is not very good. So, I want to go back to WinInet. But for this I need to find reason of blocking. Does anybody know why HttpSendRequest can block?

P.S.

It is strange that with Indy we have such performance degradation. Maybe there are some properties, parameters to increase performance?

GothAr
  • 503
  • 5
  • 16
  • Additional info. I have used Wireshark to log http communications. Here is last requests to server: https://www.dropbox.com/s/lu74qgq8yi3984j/WinInet_hang.png As you can see app initializes connection with server, server waits for data from app, app sends nothing (because hangs) server resets connection – GothAr May 08 '14 at 10:23

1 Answers1

0

So, I have finally fixed this issue.

After all trials with no success, I've re-implemented SOAP calls using WinHTTP instead of WinInet. With WinHTTP everything works normally.

GothAr
  • 503
  • 5
  • 16