You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add options for how to handle SSE client consumer oversized messages with tests and documentation
* Java API and formatting.
* Pass oversized message to dead letter queue with a type for pattern matching
* License headers, markdown whitespace, restore test, since annotation
* Separate oversized strategies for lines and events. Fix compilation in 2.12.
* binary compat, scala 3 compat. restore original default size limit values
* more binary compat. docs cleanup
* Explicitly name size variable as counting bytes.
Apache Pekko HTTP provides several configuration options for Server-Sent Events handling:
62
+
63
+
### Message Size Limits
64
+
65
+
The SSE client parser has configurable limits to handle various message sizes:
66
+
67
+
```hocon
68
+
pekko.http.sse {
69
+
# The maximum size for parsing server-sent events. Set to 0 to disable limit entirely (unlimited).
70
+
max-event-size = 8192
71
+
72
+
# The maximum size for parsing lines of a server-sent event. Set to 0 to disable limit entirely (unlimited).
73
+
max-line-size = 4096
74
+
}
75
+
```
76
+
77
+
### Oversized Message Handling
78
+
79
+
Apache Pekko HTTP uses a two-stage parsing process for SSE streams, and oversized content can be handled at either stage:
80
+
81
+
1.**Line-level parsing**: Individual lines are checked against `max-line-size`
82
+
2.**Event-level parsing**: Complete events are limited to `max-event-size`
83
+
84
+
When SSE content exceeds the configured limits, Apache Pekko HTTP provides four handling strategies that can be configured separately for lines and events:
85
+
86
+
-**fail-stream** (default): Fails the stream with an error message
87
+
-**log-and-skip**: Logs a warning and skips the oversized content, continuing stream processing
88
+
-**truncate**: Logs an info message and handles oversized content appropriately, continuing processing
89
+
-**dead-letter**: Sends the oversized content to the dead letter queue, continuing processing
90
+
91
+
**Warning about truncate strategy**: For event-level truncation, the strategy drops entire lines that would exceed event size limits rather than truncating field values. This can change event semantics in unexpected ways when non-data fields (like `id:` or `event:`) are dropped. For predictable behavior, ensure that `id:` and `event:` fields appear before `data:` fields in your SSE events, or consider using `log-and-skip` or `dead-letter` strategies instead.
92
+
93
+
```hocon
94
+
pekko.http.sse {
95
+
# How to handle lines that exceed max-line-size limit
96
+
# Options:
97
+
# "fail-stream" - Fail the stream with an error message (default)
98
+
# "log-and-skip" - Log a warning and skip the oversized line, continuing stream processing
99
+
# "truncate" - Log an info message and truncate the line to max-line-size, continuing processing
100
+
# "dead-letter" - Send oversized line to the dead letter queue, continuing processing
101
+
oversized-line-handling = "fail-stream"
102
+
103
+
# How to handle events that exceed max-event-size limit
104
+
# Options:
105
+
# "fail-stream" - Fail the stream with an error message (default)
106
+
# "log-and-skip" - Log a warning and skip the oversized event, continuing stream processing
107
+
# "truncate" - Log an info message and drop lines that would exceed max-event-size, continuing processing
108
+
# "dead-letter" - Send oversized event to the dead letter queue, continuing processing
109
+
oversized-event-handling = "fail-stream"
110
+
}
111
+
```
112
+
113
+
#### Line vs Event Handling Examples
114
+
115
+
Line-level and event-level size limits are imposed separately and their behavior is different:
116
+
- Lines are parsed one line at a time. The limits and handling strategy are applied per line. Line length limits include
117
+
the SSE field names (`id: `, `data: `, `event: `, etc.).
118
+
- Events are built from successive `data:` lines. As each line is added to the built event, the event size limit is used
119
+
to short-circuit processing of the current and/or subsequent lines. This limit is generally meant to help prevent
120
+
runaway memory usage causing an application crash from a single (possible erroneous) message from the server.
121
+
122
+
Since line and event strategies can be configured independently, you can have different behaviors for each level. For example:
0 commit comments