tomMoulard / fail2ban

Traefik plugin on fail2ban middleware
MIT License
191 stars 10 forks source link

Websocket causes a deadlock until its closed? #67

Closed AnderssonPeter closed 9 months ago

AnderssonPeter commented 1 year ago

Hi I'm not 100% sure as I'm a total noob when it comes to go. But if I read the code correctly, the lock is not released until a http connection is done sending it's content?

This works great for normal requests, but when you have a websocket it can stay open for a long long time and cause all other requests to stall until its done? (in my case that's until I close my browser)

AnderssonPeter commented 1 year ago

I'm guessing that streaming a video/music file would cause the same issue.

tomMoulard commented 1 year ago

Hello @AnderssonPeter,

Thanks for your interest in this Traefik plugin !

Could you provide a reproducible use case by any change ? This would help pinpoint the error you are facing.

AnderssonPeter commented 1 year ago

Well you start a lock before ServeHTTP, and keep that lock until after the request is done processing.

But the problem is that websockets tend to be long running, in my case I have a Home Assistant instance running that I want to protect using fail2ban.

But when you visit the home assistant, then the web page starts a websocket that is keept open until you leave the page. So this causes all other requests that go thru fail2ban block until I leave the HomeAssistant page.

I'm 99% sure that #68 will solve this issue, but I'm not 100% sure it wont cause any other issues as I'm by no means a go developer.

AnderssonPeter commented 1 year ago

@tomMoulard did my explanation help?