Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permessage-deflate for WebSockets #615

Open
stefan-reich opened this issue Sep 29, 2021 · 2 comments
Open

permessage-deflate for WebSockets #615

stefan-reich opened this issue Sep 29, 2021 · 2 comments

Comments

@stefan-reich
Copy link

stefan-reich commented Sep 29, 2021

WebSocket compression (permessage-deflate) is now well-supported in browsers.

Has anyone attempted to add it to NanoHTTPD?

(For context: For very interactive pages I have moved to a mode where the whole page is delivered through a websocket as this simplifies dynamic page updates a lot, so at that moment I have lost the automatic GZIP compression for HTML content. Example page with a lot of WebSocket activity served directly from NanoHTTPD.)

@NoahAndrews
Copy link

I would strongly consider using Java-WebSocket over NanoHTTPD. It has compression support IIRC, and has generally seemed significantly more reliable to me. I had a lot of weird issues with WebSockets in NanoHTTPD when I tried it.

You'll have to have WebSocket traffic be on a different port, but that's not the end of the world.

@stefan-reich
Copy link
Author

Yes there were issues at some point with NanoHTTPD's websockets. Not sure which version it was or when, but NanoHTTPD added spurious null bytes at the end of WebSocket messages. Since I fixed that, everything is running smoothly.

If I switch to a completely different library, I will have to change a lot of infrastructure. As it is now, I can parse request parameters, headers etc. exactly the same way between a HTTP request and a WebSocket. And NGL, having the same port for http and websockets is pretty nice too.

I may actually add the compression myself, I think it's doable (although the RFC makes it a little more complicated than one might expect). Websites completely built on NanoHTTPD are my ticket to fame, lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants