wsj0413 / kaptcha

Automatically exported from code.google.com/p/kaptcha
Other
0 stars 0 forks source link

wrong captcha after IE9 sends 2 requests and cuts one off #69

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
User enters the correct captcha from the image but it is not the generated one.

If you use IE9 (at least), sometimes the captcha is requested twice.

I tried suffixing a random number but I doesn't help.

Access Log (notice the status code 500):
"GET /WebApp/kaptcha.jpg HTTP/1.1" 200 4285 
"GET /WebApp/kaptcha.jpg HTTP/1.1" 500 5277 

So one of the 2 requests IE9 cuts off, and server throws:
"java.net.SocketException: Connection reset by peer: socket write error"

If the first request is cut off, everything is ok. 

If the second request is cut off, the session contains the second captcha text, 
but user still sees first captcha image, hence the problem.

You should set the session attribute after the image has been written. This 
way, any failed request will not change the session.

In FF12 it works. I have never tried with anything else.

Original issue reported on code.google.com by supersm...@gmail.com on 6 Jun 2012 at 2:07

GoogleCodeExporter commented 8 years ago
Forgot to mention, the requests are handled in two different threads. That's 
why sometimes the first one is cut off and sometimes the second one.

Original comment by supersm...@gmail.com on 6 Jun 2012 at 2:09

GoogleCodeExporter commented 8 years ago
I am having the same problema. I mean, the captcha is also requested twice in 
FireFox 14.0.1. In my case, in IE9 and Chrome 21.0 works fine.

Original comment by diegoluc...@gmail.com on 13 Aug 2012 at 5:56

GoogleCodeExporter commented 8 years ago
any plan to fix this issue?

Original comment by Fengying...@gmail.com on 7 Dec 2012 at 10:09

GoogleCodeExporter commented 8 years ago
As soon as there is a valid suggestion on how to fix it, I'll apply it.

Original comment by latch...@gmail.com on 7 Dec 2012 at 10:13

GoogleCodeExporter commented 8 years ago
Well, I said: "You should set the session attribute after the image has been 
written". I think the code should go like this:

ImageIO.write(bi, "jpg", out);
req.getSession().setAttribute(this.sessionKeyValue, capText);                
req.getSession().setAttribute(this.sessionKeyDateValue, new Date()); 

It's simple. :)

Original comment by supersm...@gmail.com on 22 Dec 2012 at 10:04

GoogleCodeExporter commented 8 years ago
Right, but that doesn't explain why IE is requesting the image 2x. That is the 
core of the issue and that is the part that needs to be resolved.

Original comment by latch...@gmail.com on 22 Dec 2012 at 5:46

GoogleCodeExporter commented 8 years ago
Well, I think the core issue is that your code does not handle potential 
exceptions and leaves session attributes set incorrectly. :(

Original comment by supersm...@gmail.com on 25 Dec 2012 at 7:02

GoogleCodeExporter commented 8 years ago
now i see your point, but i'd like to get an understanding of why ie is causing 
the server to throw that exception.

Original comment by latch...@gmail.com on 26 Dec 2012 at 11:50

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r138.

Original comment by whiche...@gmail.com on 26 Dec 2012 at 11:58