简体   繁体   English

Webservice - 操作已超时

[英]Webservice - Operation has timed out

The project that I'm working on is the following: I've got a Java webservice that encrypts data (Des, 3Des).我正在从事的项目如下:我有一个加密数据的 Java Web 服务(Des、3Des)。 The data is send from a C# application.数据是从 C# 应用程序发送的。 With I want to encrypt/decrypt a file of the size 1MB.我想加密/解密大小为 1MB 的文件。 I'll get an exception.我会得到一个例外。

The file are put in a byte[], in bitformat and send to the Java webservice for encryption/decryption.该文件以位格式放入 byte[] 中,并发送到 Java Web 服务以进行加密/解密。 After the webservice has done that it needs to send the encrypted/decrypted data back.在 web 服务完成之后,它需要将加密/解密的数据发回。

With small files I've got no problem but the file of the size 1MB or greater the exception is thrown in the C# application, the errors has the following message: WebException was unhandled: The operation has timed out对于小文件,我没有问题,但大小为 1MB 或更大的文件在 C# 应用程序中抛出异常,错误有以下消息: WebException was unhandled: The operation has timed out

This error is thrown after approximately: 1min40sec大约在:1min40sec 后抛出此错误

I've read different posts on StackOverflow but they seem always to work with WebRequest and WebResponse.我在 StackOverflow 上阅读过不同的帖子,但它们似乎总是与 WebRequest 和 WebResponse 一起使用。 I am not working with that, the code I use to call my webservice is:我没有使用它,我用来调用我的网络服务的代码是:

public byte[] TEncode(byte[] input, byte[] key)
{
    return _webservice.TDesEncode(input, key);
}

Has anyone some advice what I can do to fix this problem?有没有人建议我可以做些什么来解决这个问题?

EDIT Tried to increase the session timeout in the app.config file like:编辑试图增加 app.config 文件中的会话超时,如:

<system.web>
<sessionState timeout="20"></sessionState>
</system.web>

Thanks in advance Martijn在此先感谢马丁

Sounds like you need to increase the timeout.听起来你需要增加超时。 Check out this site for an explaination and possible fix.查看此站点以获取解释和可能的修复。

Try to call encode function localy and measure how much time it needs to encode, try to use maximum allowed file size to get the worst case.尝试在本地调用编码函数并测量它需要多少时间进行编码,尝试使用最大允许的文件大小来获得最坏的情况。

If time is optimal for you - increase service timeout to that value.如果时间最适合您 - 将服务超时增加到该值。

If not - it may be wise to either optimize encoding function, or encode on client/server side and transfer already encrypted file.如果不是 - 优化编码功能或在客户端/服务器端进行编码并传输已加密的文件可能是明智之举。

Last approach is better from security point as in your sample you pass unencrypted array of bytes to, possibly, remote service - in this case it is very vulnerable to network traffic sniffing.从安全角度来看,最后一种方法更好,因为在您的示例中,您将未加密的字节数组传递给可能的远程服务 - 在这种情况下,它很容易受到网络流量嗅探的攻击。

I think you need to check whether the timeout is caused during the streaming time for the data to hit the service host, or if the actual encryption is taking too long.我认为您需要检查是否在数据到达服务主机的流式传输时间内导致超时,或者实际加密时间是否太长。 If its the encryption, you may need to revise this.如果是加密,您可能需要修改它。

I know you're testing with 1MB, but, at 1GB if you're running this on a LAN, with Gigabit Ethernet, it would take at least 10-15secs, on a good network, just to send the request to the service host.我知道您正在使用 1MB 进行测试,但是,如果您在 LAN 上使用千兆以太网运行它,则在 1GB 时,在良好的网络上,将请求发送到服务主机至少需要 10-15 秒.

hope the below code will work..希望下面的代码能工作..

var objNotificationCreation = new BS_INTELATRAC_DES_SI_Intelatrac_NotificationCreation_InS
{
Credentials = new NetworkCredential("user name","password")//if needed,
Timeout=int.MaxValue
};

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

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