http4s / blaze

Blazing fast NIO microframework and Http Parser
Apache License 2.0
349 stars 63 forks source link

`active_request_count` gauge doesn't decrease on WebSocket disconnect #671

Open mr-git opened 5 years ago

mr-git commented 5 years ago

I just made use of epimetheus-http4s metrics, which look to do almost the same as http4s' metricsOps, and noticed, that active_request_count never goes down for WebSocket connections.

I am using http4s - 0.20.0 and epimetheus-http4s - 0.2.0...

Not sure if it is related, but I get the following exceptions at server shutdown. If WebSocket connection was opened, then at shutdown time:

2019-05-02 22:10:20,981 ERROR [blaze-selector-1][org.http4s.blaze.channel.nio1.NIO1HeadStage] ip: s: c: p: g: t: - Abnormal NIO1HeadStage termination
java.nio.channels.ShutdownChannelGroupException: null
    at org.http4s.blaze.channel.nio1.SelectorLoop.killSelector(SelectorLoop.scala:225)
    at org.http4s.blaze.channel.nio1.SelectorLoop.org$http4s$blaze$channel$nio1$SelectorLoop$$runLoop(SelectorLoop.scala:185)
    at org.http4s.blaze.channel.nio1.SelectorLoop$$anon$1.run(SelectorLoop.scala:67)
    at java.base/java.lang.Thread.run(Thread.java:835)

If WebSocket was opened and then closed by client-side, at server shutdown there are:

2019-05-02 22:12:04,365 ERROR [blaze-selector-1][org.http4s.blaze.channel.nio1.NIO1HeadStage] ip: s: c: p: g: t: - Abnormal NIO1HeadStage termination
java.nio.channels.ShutdownChannelGroupException: null
    at org.http4s.blaze.channel.nio1.SelectorLoop.killSelector(SelectorLoop.scala:225)
    at org.http4s.blaze.channel.nio1.SelectorLoop.org$http4s$blaze$channel$nio1$SelectorLoop$$runLoop(SelectorLoop.scala:185)
    at org.http4s.blaze.channel.nio1.SelectorLoop$$anon$1.run(SelectorLoop.scala:67)
    at java.base/java.lang.Thread.run(Thread.java:835)
2019-05-02 22:12:04,365 ERROR [blaze-selector-1][org.http4s.server.blaze.Http1ServerStage$$anon$1] ip: s: c: p: g: t: - Fatal Error: Error in requestLoop()
java.nio.channels.ShutdownChannelGroupException: null
    at org.http4s.blaze.channel.nio1.SelectorLoop.killSelector(SelectorLoop.scala:225)
    at org.http4s.blaze.channel.nio1.SelectorLoop.org$http4s$blaze$channel$nio1$SelectorLoop$$runLoop(SelectorLoop.scala:185)
    at org.http4s.blaze.channel.nio1.SelectorLoop$$anon$1.run(SelectorLoop.scala:67)
    at java.base/java.lang.Thread.run(Thread.java:835)
2019-05-02 22:12:04,364 ERROR [blaze-selector-4][org.http4s.blaze.channel.nio1.NIO1HeadStage] ip: s: c: p: g: t: - Abnormal NIO1HeadStage termination
java.nio.channels.ShutdownChannelGroupException: null
    at org.http4s.blaze.channel.nio1.SelectorLoop.killSelector(SelectorLoop.scala:225)
    at org.http4s.blaze.channel.nio1.SelectorLoop.org$http4s$blaze$channel$nio1$SelectorLoop$$runLoop(SelectorLoop.scala:185)
    at org.http4s.blaze.channel.nio1.SelectorLoop$$anon$1.run(SelectorLoop.scala:67)
    at java.base/java.lang.Thread.run(Thread.java:835)
2019-05-02 22:12:04,365 ERROR [blaze-selector-4][org.http4s.server.blaze.Http1ServerStage$$anon$1] ip: s: c: p: g: t: - Fatal Error: Error in requestLoop()
java.nio.channels.ShutdownChannelGroupException: null
    at org.http4s.blaze.channel.nio1.SelectorLoop.killSelector(SelectorLoop.scala:225)
    at org.http4s.blaze.channel.nio1.SelectorLoop.org$http4s$blaze$channel$nio1$SelectorLoop$$runLoop(SelectorLoop.scala:185)
    at org.http4s.blaze.channel.nio1.SelectorLoop$$anon$1.run(SelectorLoop.scala:67)
    at java.base/java.lang.Thread.run(Thread.java:835)
2019-05-02 22:12:04,365 ERROR [blaze-selector-1][org.http4s.blaze.channel.nio1.NIO1HeadStage] ip: s: c: p: g: t: - Abnormal NIO1HeadStage termination
java.nio.channels.ShutdownChannelGroupException: null
    at org.http4s.blaze.channel.nio1.SelectorLoop.killSelector(SelectorLoop.scala:225)
    at org.http4s.blaze.channel.nio1.SelectorLoop.org$http4s$blaze$channel$nio1$SelectorLoop$$runLoop(SelectorLoop.scala:185)
    at org.http4s.blaze.channel.nio1.SelectorLoop$$anon$1.run(SelectorLoop.scala:67)
    at java.base/java.lang.Thread.run(Thread.java:835)
2019-05-02 22:12:04,365 ERROR [blaze-selector-4][org.http4s.blaze.channel.nio1.NIO1HeadStage] ip: s: c: p: g: t: - Abnormal NIO1HeadStage termination
java.nio.channels.ShutdownChannelGroupException: null
    at org.http4s.blaze.channel.nio1.SelectorLoop.killSelector(SelectorLoop.scala:225)
    at org.http4s.blaze.channel.nio1.SelectorLoop.org$http4s$blaze$channel$nio1$SelectorLoop$$runLoop(SelectorLoop.scala:185)
    at org.http4s.blaze.channel.nio1.SelectorLoop$$anon$1.run(SelectorLoop.scala:67)
    at java.base/java.lang.Thread.run(Thread.java:835)
mr-git commented 5 years ago

http4s/blaze#672 looks to have similar exception