使用 NetTcpBinding 计算 WCF 中所需的 MaxReceivedMessageSize [英] Figuring out the required MaxReceivedMessageSize in WCF with NetTcpBinding

查看:27
本文介绍了使用 NetTcpBinding 计算 WCF 中所需的 MaxReceivedMessageSize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 WCF 中使用 NetTcpBinding,我想发送一个不超过 1 MB 大小的流.我已将 MaxReceivedMessageSize 设置为一个非常高的数字,当然效果很好.

I'm using NetTcpBinding in WCF and i want to send a Stream which does not exceed the size of 1 MB. I have set the MaxReceivedMessageSize to a really high number and that works fine of course.

但我很好奇:

将 MaxReceivedMessageSize 设置为非常高的数字是否有任何(负面)影响,或者将其设置为略高于我实际想要发送/接收的大小是否有用?

Does setting the MaxReceivedMessageSize to a very hight number have any (negative) impact or would it be useful to set it just above the size I actually want to send/receive?

使用 NetTcpBinding 传输流时,我可以期待什么样的开销?意思是:当我发送 1 MB 的流时,我的 MaxReceivedMessageSize 必须有多大?

What kind of overhead can I expect when using the NetTcpBinding to transfer a stream? Meaning: when I send a stream of 1 MB, how large does my MaxReceivedMessageSize has to be?

推荐答案

设置 MaxReceivedMessageSize 允许您调整端点以拒绝过大的消息.当该端点向公众公开时,这可能会特别令人感兴趣,正如我们所知,其中有相当多的愚蠢和恶意用户.

Setting MaxReceivedMessageSize allows you to tune your endpoint to reject oversized messages. This may be of particular interest when that endpoint is exposed to the public, which as we know, has it's fair share of dumb and malicious users.

通常,如果您知道最大消息大小,您应该使用它.

Generally, if you know the max message size, you should work with that.

有些人可能会有所不同,但在我看来,1Mb = 1048576 字节 (1024*1024).我还会为诸如消息信封之类的杂项添加一个缓冲区.所以 1048576 + 1024 = 1049600 对于预期的 1Mb 消息来说似乎是一个合理的大小.

Some people may differ, but in my mind 1Mb = 1048576 bytes (1024*1024). I would also add a buffer for incidentals such as the message envelope. So 1048576 + 1024 = 1049600 would seem like a reasonable size for an expected 1Mb message.

这篇关于使用 NetTcpBinding 计算 WCF 中所需的 MaxReceivedMessageSize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆