1

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

Daneo
  • 508
  • 3
  • 17
Martijn Haex
  • 137
  • 1
  • 11

4 Answers4

0

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

Lucas B
  • 11,793
  • 5
  • 37
  • 50
  • Yeah, my thought also but most solutions didn't work that I've read here about this topic. I'm going to try this one and let you'll know if it solved my error. – Martijn Haex Oct 22 '12 at 18:37
  • Tried to implement the given solution but failed, same error returned again. – Martijn Haex Oct 22 '12 at 18:48
0

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.

Nogard
  • 1,779
  • 2
  • 18
  • 21
  • The Java webservices devides the data in 30 seperate threads to speed up the encryption/decryption, in the app.config file in my C# application I already increased by service timeout ... but it still gives me the error after the same time (1min40sec). I want to encrypt/decrypt a file of 1GB as fast as possible --> but I started with 1MB, so in my C# application I will divide the amount of data also. But I already got a problem with a testcase. – Martijn Haex Oct 22 '12 at 18:49
0

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.

TheITGuy
  • 722
  • 4
  • 15
0

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