[1.3] Memory leak in SockJS
If a web browser using the EventBus bridge doesn't disconnect cleanly (for example, its WiFi connection dies or perhaps the user puts the machine to sleep), Vert.x will continue to pile up pending writes until all memory is exhausted. Full report here.
I replicated your issue using 2.0 (and 1.3).
In fact there appear to be two separate issues - one is a memory leak when using streaming transports, and the connection is closed because more than maxBytesStreaming data has been sent but the connection is never comes back. Please see this commit for this https://github.com/vert-x/vert.x/commit/5201ec0723874f70ac2f994102513d1543e9f668 The relevant part is we now always call setTimer when resetListener() is called.
However, there is a more fundamental issue here when using any streaming transport, or websockets. If the client "goes to sleep", or the network is lost. Then no notification will be received on the server - this is because the connection is still alive in the eyes of the operating system. So basically, the server doesn't know it's gone so doesn't know to close any resources on the server.
These kinds of issues are normally resolved by pinging from client to server. But SockJS does not support any such pinging. This has been discussed quite a lot on the SockJS google group. https://groups.google.com/forum/?fromgroups#!searchin/sockjs/sleep/sockjs/6p82YgsOxzM/TZs6pCHWb3YJ (there are other threads too)
Since the sockjs client doesn't support sending heartbeats, there's nothing much we can do in the Vert.x implementation to help with this case where the user is using SockJS directly - so the user would need to implement their own pinging in their application. However, this is actually pretty straightforward to do just setInterval to send a ping every few seconds and install a SockJS application on the server which closes the SockJSSession if it doesn't receive the ping in time. We should add that to the docs.
For uses who are using SockJS via vertxbus.js (like you) there may be something we can add in that library to do the pinging for you. This would probably be a good idea. I'll look into that.
I have now implemented a pinger in vertxbus.js, along with a ping checker in EventBusBridge. https://github.com/vert-x/vert.x/commit/33e93852e70fc12497bb57b6171f109b2f5aa70d
Regarding Vert.x 1.x, we only do releases from master and don't maintain multiple branches for releases, so I'd recommended grabbing the vertxbus.js from the above commit, and manually applying that commit against your own patched version of 1.x, it's just a few lines of code so should be pretty straightforward :)
I realize you're trying to EOL Vert.x 1.x, but the fact of the matter is that 2.0 isn't released, yet, and you've got a non-trivial installed base of 1.x out in the wild. This issue has impacted every application I've built on Vert.x, as well as those of other users, based on mailing list traffic. I think this warrants a new release; if you don't support your existing users, what incentive do we have to migrate or adopt the new version?
We don't have the resources to maintain more than one branch for releases.
The fixes are pretty straightforward and should be pretty easy to apply manually to 1.3.1.
Please remember that we are supporting you, by spending many hours per day answering questions on the forums and by telling you how this can be fixed. This goes well beyond what I have to do contractually. Remember you are getting Vert.x and all support for free.
This is not a commercial product where you have bought a support contract, and you can't expect a similar level of support, but I think you'll find it's pretty damned good here compared to most open source projects.
Vert.x 2.0 will be released this week if all goes to plan, at which point the latest production version will be 2.0. We are not EOLing 1.3.1.final any more than 1.3.1 EOL'd 1.3.0 and 1.3.0 EOL'd the release before that. There is no end of line because we only maintain one line and 2.0 is the latest release in that line.
Hope that helps.
How would you feel about having a user maintained (but official) 1.3.x branch in the github repository? I really don't like the idea of everyone with current deployments of Vertx having to create their own bespoke versions to fix issues such as these. If we can share the effort, it will be much better for everyone in the long-term.
Anyone is free to fork and patch any github repository. That's what github is all about.
I think @j2ro is suggesting that the 1.3.x branch be maintained in the main vert.x repository. I agree that having unofficial, patched forks floating around is a bad idea.
Yes, exactly.
By "official", I meant within the vert.x repository, available to download via the vertx.io website, and available on the main Maven repository using the same groupId and artifactId of the current vertx 1.3.x releases.
This branch wouldn't need to be maintained by @purplefox et al (although the occasional code review would be really cool), but by other members of the community.
Let's revisit this once I've got 2.0 out