简体   繁体   English

基于 TCP 的基本绑定的 WCF 如何不可靠?

[英]How WCF with basic binding over TCP is not reliable?

Since i had bad introduction that confused people, I am editing the question and removing the introduction I previously made.由于我的介绍很糟糕,使人们感到困惑,因此我正在编辑问题并删除我之前所做的介绍。

Now, here is the business case for which now I have concerns.现在,这是我现在担心的商业案例。 C# pseudocode: C#伪代码:

 Array.ForEach(files, filename =>
                    {
                        try
                        {
                           WcfServiceClient wcfClient = new WcfServiceClient();
                           wcfClient.SomeMethodWhichPostsFile(filename);
                        }
                        catch (Exception ex)
                        {
                            LogException(ex)
                        }
                    }
                );

I am confused because of existence of WSBinding which is reliable, and basicHTTPBinding is not.我很困惑,因为 WSBinding 的存在是可靠的,而 basicHTTPBinding 不是。 I know that WSBinding with reliable sessions guarantees delivery, order, content is encrypted etc. But in the case I described with pseudocode, according to my opinion I have all of these supported even with basicHttpBinding and HTTPS over TCP.我知道具有可靠会话的 WSBinding 可以保证交付、订单、内容被加密等。但是在我用伪代码描述的情况下,根据我的观点,即使使用 basicHttpBinding 和基于 TCP 的 HTTPS,我也支持所有这些。 TCP provides me reliability, order guarantees and HTTPS encryption. TCP 为我提供可靠性、顺序保证和 HTTPS 加密。

  1. (1. is removed) Am I right related to previous? (1. 被删除) 我和以前的有关系吗? Or to rephrase: is there an example to show that basicHttpBindind under specified conditions can not provide the same features as WS binding with reliable sessions?或者换个说法:是否有一个例子表明 basicHttpBindind 在指定条件下无法提供与具有可靠会话的 WS 绑定相同的功能?

  2. My business case requires to accept WCF calls by the order they are issued.我的业务案例要求按照发出的顺序接受 WCF 调用。 If I send them synchronously from the client in a foreach loop (as shown in pseudo code), I assume the order at the server is guaranteed regardless if those are sent within one TCP connection or not, since I am waiting for the response and then I send another request.如果我在 foreach 循环中从客户端同步发送它们(如伪代码所示),我假设服务器上的顺序是有保证的,无论它们是否在一个 TCP 连接内发送,因为我正在等待响应,然后我发送另一个请求。 Even loadbalancer can not disorder messages here since there is no parallelization, messages are sent one by one synchronously.这里即使是负载均衡器也无法将消息打乱,因为没有并行化,消息是一条一条同步发送的。 I assume disordering could happen only if I send messages without waiting for response in fire and forget manner and I use different TCP connections.我认为只有在我发送消息而不等待响应的情况下才会发生混乱,并且我使用不同的 TCP 连接。 So, am I right here?那么,我在这里吗? :) :)

There are different meanings of the term reliability and the interpretation also depends on the context.可靠性一词有不同的含义,解释也取决于上下文。 Your interpretation of reliability in your question is message is delivered .您在问题中对可靠性的解释是消息已传递 The interpretation of reliability in the source you cite is instead message is delivered exactly once .您引用的来源中可靠性的解释是消息只传递一次 Your confusion comes from taking the statement "HTTP is not reliable" which was meant for one interpretation of reliability and using it in the your different interpretation of reliability.您的困惑来自于采用“HTTP 不可靠”这一陈述,该陈述对可靠性的一种解释,并在您对可靠性的不同解释中使用它。

HTTP cannot guarantee that the message gets only delivered once, it can at most guarantee that the message is delivered at least once . HTTP 不能保证消息只被传递一次,它最多可以保证消息至少传递一次 It can happen that the underlying TCP connection breaks while sending the request or receiving the response.在发送请求或接收响应时,底层 TCP 连接可能会中断。 In this case the client might ignore the problem or retry, which might result in no message delivered (ignoring errors while sending request) but also the same message delivered multiple times (retrying if connections breaks during response).在这种情况下,客户端可能会忽略问题或重试,这可能会导致没有消息传递(在发送请求时忽略错误),但也会多次传递相同的消息(如果在响应期间连接中断,则重试)。 By retrying until the response is received successfully one can guarantee that the message is received at least once, which is your interpretation of reliability but not the one from the statement you cite.通过重试直到成功收到响应,可以保证至少收到一次消息,这是您对可靠性的解释,而不是您引用的声明中的解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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