C# WCF Service resending data after reconnect? What property is this?
-
24-06-2021 - |
문제
A little background. I am working in C# with .NET Framework 4. My binding is WsHttpBinding
with no security on it currently. I have a WCF client that reports a heartbeat to the WCF server every second or so. This heartbeat is just an unsigned integer.
I pull the network cable for a few minutes, then reconnect it. All the missed heartbeat values come flooding in. What WCF configuration property is making this happen? I would expect that those messages would be dropped and I would just receive whatever the latest heartbeat was.
해결책
Based on the description, it sounds like this could be due to a long timeout for the WCF service in the client.
Since the requests are async and since you had previously established a connection with the server, I would expect that this would be due to the send timeout.
Here is a good MSDN blog entry on Timeouts in WCF and their default values.
다른 팁
This could well be because you are not specifying an instancing mode for the service.
If not then it will defaults to per-session. This means that under the covers the WCF runtime is implementing one of the WS-* specifications called WS-ReliableMessaging, which tries to guarantee delivery of messages between the consumer and service once the session has been established.
I imagine that if you waited for a long time (10 minutes by default I think) you would start to see evidence of dropped messages.
Alternatively, if you configure your service with a per-call instancing mode I imagine you will not see this behavior.