简体   繁体   中英

IIS Presumably blocks outgoing WCF messages over a certain size

I have ported over an old application to asp.net core 6. Its an API that gets incoming requests and communicates over net.tcp to a wcf service that i have no control over. The bindings and xml reader quotas are all set high. Everything works ok when I transfer simple messages. However one feature requires me to send base64 encoded images to the wcf service. And this is when i get this error.

The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of 10675199.02:48:05.4775807. The time allotted to this operation may have been a portion of a longer timeout.

In my testing an image of 8kb goes through normally but one on 16kb and above does not go through.

Further more. If i launch my asp.net application via .exe file instead of IIS then everything goes through fine. This leads me to believe that something in IIS blocks my xml transfer. I have tried modifying "uploadReadAheadSize" after googling but that had no effect. Im at a loss here as i would like to use IIS to host this API.

Ive tries to enable tracing but cannot get that working on my solution.

Current binding looks like this, although ive tried increasing buffer sizes also, but i removed to make it more like how it looks on the service side.

 NetTcpBinding binding = new NetTcpBinding();

        binding.TransferMode = TransferMode.Streamed;
        binding.Security.Mode = SecurityMode.None;
        binding.ReceiveTimeout = TimeSpan.FromSeconds(20);
        binding.SendTimeout = TimeSpan.FromSeconds(20);
        binding.MaxReceivedMessageSize = 650000;

        XmlDictionaryReaderQuotas myReaderQuotas = new XmlDictionaryReaderQuotas();
        myReaderQuotas.MaxStringContentLength = 2147483647;
        myReaderQuotas.MaxNameTableCharCount = 2147483647;
        myReaderQuotas.MaxArrayLength = 2147483647;
        myReaderQuotas.MaxBytesPerRead = 2147483647;
        myReaderQuotas.MaxDepth = 64;

This error may be caused by the default limits defined in service configuration are too low (MaxItemsInObjectGraph, MaxReceivedMessageSize, MaxBufferPoolSize, MaxBufferSize, MaxArrayLength).

you can try fix by increasing the values in the config file.

<binding name="MyCoolBinding" maxreceivedmessagesize="10000000" maxbuffersize="10000000" maxbufferpoolsize="10000000">

More information you can refer to this link: http://nerdwords.blogspot.com/2008/01/wcf-error-socket-connection-was-aborted.html .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM