Webservice - Operation has timed out

8.7k Views Asked by At

The project that I'm working on is the following: I've got a Java webservice that encrypts data (Des, 3Des). The data is send from a C# application. With I want to encrypt/decrypt a file of the size 1MB. I'll get an exception.

The file are put in a byte[], in bitformat and send to the Java webservice for encryption/decryption. After the webservice has done that it needs to send the encrypted/decrypted data back.

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

This error is thrown after approximately: 1min40sec

I've read different posts on StackOverflow but they seem always to work with WebRequest and 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:

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

Thanks in advance Martijn

4

There are 4 best solutions below

1
On

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.

2
On

Sounds like you need to increase the timeout. Check out this site for an explaination and possible fix.

1
On

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.

0
On

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
};