taoensso / sente

Realtime web comms library for Clojure/Script
https://www.taoensso.com/sente
Eclipse Public License 1.0
1.74k stars 193 forks source link

WebSocket terminates with "Connection Closed: 1006" if a message bigger than 64 kB is sent #389

Closed KaliszAd closed 3 years ago

KaliszAd commented 3 years ago

I am investigating a failure involving WebSockets with Sente from ClojureScript to a Clojure backend using Sente and Aleph. The connection terminates with error code 1006 (https://datatracker.ietf.org/doc/html/rfc6455#section-7.4.1). I managed to create messages just under 64 kB that work fine, messages just over 64 kB always fail.

I haven't found any such limit in Aleph or Sente (looked for anything starting with 64 and 65), can somebody please explain, what am I doing wrong? Could this be a problem with Transit or Aleph? Are there any other similar hard coded limitations for the message/ payload size?

Update: thanks to @hiredman in the Clojure Slack channel the limit is written here: https://github.com/clj-commons/aleph/blob/master/src/aleph/http/server.clj#L728 I still have no clear idea whether to increase the size or rather to split the communication into multiple parts. From looking into get-sch-adapter in taoensso.sente.server-adapters.aleph the implementation doesn't seem to accept any options that could be consumed by websocket-connection in aleph.http.

KaliszAd commented 3 years ago

I've added better support for Aleph options with this PR: Add support for websocket-connection options #390 This enables you to increase max-frame-payload to a more suitable size e.g. 1048576 and max-frame-size to 2097152 (bytes). This pushes the limit in such a way that it's no longer a problem for our use case.