blob: 83c52b1a6169625abe91c15925e928127bd06789 [file] [log] [blame]
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +02001 -----------------------------------------------
2 Stream Processing Offload Engine (SPOE)
3 Version 1.0
4 ( Last update: 2016-11-07 )
5 -----------------------------------------------
6 Author : Christopher Faulet
7 Contact : cfaulet at haproxy dot com
8
9
10SUMMARY
11--------
12
13 0. Terms
14 1. Introduction
15 2. SPOE configuration
16 2.1. SPOE scope
17 2.2. "spoe-agent" section
18 2.3. "spoe-message" section
19 2.4. Example
20 3. SPOP specification
21 3.1. Data types
22 3.2. Frames
23 3.2.1. Frame capabilities
24 3.2.2. Frame types overview
25 3.2.3. Workflow
26 3.2.4. Frame: HAPROXY-HELLO
27 3.2.5. Frame: AGENT-HELLO
28 3.2.6. Frame: NOTIFY
29 3.2.7. Frame: ACK
30 3.2.8. Frame: HAPROXY-DISCONNECT
31 3.2.9. Frame: AGENT-DISCONNECT
32 3.3. Events & messages
33 3.4. Actions
34 3.5. Error & timeouts
35
36
370. Terms
38---------
39
40* SPOE : Stream Processing Offload Engine.
41
42 A SPOE is a filter talking to servers managed ba a SPOA to offload the
43 stream processing. An engine is attached to a proxy. A proxy can have
44 several engine. Each engine is linked to an agent and only one.
45
46* SPOA : Stream Processing Offload Agent.
47
48 A SPOA is a service that will receive info from a SPOE to offload the
49 stream processing. An agent manages several servers. It uses a backend to
50 reference all of them. By extension, these servers can also be called
51 agents.
52
53* SPOP : Stream Processing Offload Protocol, used by SPOEs to talk to SPOA
54 servers.
55
56 This protocol is used by engines to talk to agents. It is an in-house
57 binary protocol described in this documentation.
58
59
601. Introduction
61----------------
62
63SPOE is a feature introduced in HAProxy 1.7. It makes possible the
64communication with external components to retrieve some info. The idea started
65with the problems caused by most ldap libs not working fine in event-driven
66systems (often at least the connect() is blocking). So, it is hard to properly
67implement Single Sign On solution (SSO) in HAProxy. The SPOE will ease this
68kind of processing, or we hope so.
69
70Now, the aim of SPOE is to allow any kind of offloading on the streams. First
71releases, besides being experimental, won't do lot of things. As we will see,
72there are few handled events and even less actions supported. Actually, for
73now, the SPOE can offload the processing before "tcp-request content",
74"tcp-response content", "http-request" and "http-response" rules. And it only
75supports variables definition. But, in spite of these limited features, we can
76easily imagine to implement SSO solution, ip reputation or ip geolocation
77services.
78
79
802. SPOE configuration
81----------------------
82
83Because SPOE is implemented as a filter, To use it, you must declare a "filter
84spoe" line in a proxy section (frontend/backend/listen) :
85
86 frontend my-front
87 ...
88 filter spoe [engine <name>] config <file>
89 ...
90
91The "config" parameter is mandatory. It specififies the SPOE configuration
92file. The engine name is optional. It can be set to declare the scope to use in
93the SPOE configuration. So it is possible to use the same SPOE configuration
94for several engines. If no name is provided, the SPOE configuration must not
95contain any scope directive.
96
97We use a separate configuration file on purpose. By commenting SPOE filter
98line, you completly disable the feature, including the parsing of sections
99reserved to SPOE. This is also a way to keep the HAProxy configuration clean.
100
101A SPOE configuration file must contains, at least, the SPOA configuration
102("spoe-agent" section) and SPOE messages ("spoe-message" section) attached to
103this agent. Unused messages (not reference in "spoe-agent" section) will be
104ignored.
105
106IMPORTANT : The configuration of a SPOE filter must be located in a dedicated
107file. But the backend used by a SPOA must be declared in HAProxy configuration
108file.
109
1102.1. SPOE scope
111-------------------------
112
113If you specify an engine name on the SPOE filter line, then you need to define
114scope in the SPOE configuration with the same name. You can have several SPOE
115scope in the same file. In each scope, you must define one and only one
116"spoe-agent" section to configure the SPOA linked to your SPOE and several
117"spoe-message" sections to describe messages sent to servers mananger by your
118SPOA.
119
120A SPOE scope starts with this kind of line :
121
122 [<name>]
123
124where <name> is the same engine name specified on the SPOE filter line. The
125scope ends when the file ends or when another scope is found.
126
127 Example :
128 [my-first-engine]
129 spoe-agent my-agent
130 ...
131 spoe-message msg1
132 ...
133 spoe-message msg2
134 ...
135
136 [my-second-engine]
137 ...
138
139If no engine name is provided on the SPOE filter line, no SPOE scope must be
140found in the SPOE configuration file. All the file is considered to be in the
141same anonymous and implicit scope.
142
1432.2. "spoe-agent" section
144--------------------------
145
146For each engine, you must define one and only one "spoe-agent" section. In this
147section, you will declare SPOE messages and the backend you will use. You will
148also set timeouts and options to customize your agent's behaviour.
149
150
151spoe-agent <name>
152 Create a new SPOA with the name <name>. It must have one and only one
153 "spoe-agent" definition by SPOE scope.
154
155 Arguments :
156 <name> is the name of the agent section.
157
158 following keywords are supported :
Christopher Faulet48026722016-11-16 15:01:12 +0100159 - maxconnrate
160 - maxerrrate
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200161 - messages
Christopher Fauletea62c2a2016-11-14 10:54:21 +0100162 - option continue-on-error
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200163 - option var-prefix
Christopher Faulet03a34492016-11-19 16:47:56 +0100164 - timeout hello|idle|processing
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200165 - use-backend
166
167
Christopher Faulet48026722016-11-16 15:01:12 +0100168maxconnrate <number>
169 Set the maximum number of connections per second to <number>. The SPOE will
170 stop to open new connections if the maximum is reached and will wait to
171 acquire an existing one. So it is important to set "timeout hello" to a
172 relatively small value.
173
174
175maxerrrate <number>
176 Set the maximum number of errors per second to <number>. The SPOE will stop
177 its processing if the maximum is reached.
178
179
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200180messages <msg-name> ...
181 Declare the list of SPOE messages that an agent will handle.
182
183 Arguments :
184 <msg-name> is the name of a SPOE message.
185
186 Messages declared here must be found in the same engine scope, else an error
187 is triggered during the configuration parsing. You can have many "messages"
188 lines.
189
190 See also: "spoe-message" section.
191
192
Christopher Fauletea62c2a2016-11-14 10:54:21 +0100193option continue-on-error
194 Do not stop the events processing when an error occurred on a stream.
195
196 By default, for a specific stream, when an abnormal/unexpected error occurs,
197 the SPOE is disabled for all the transaction. So if you have several events
198 configured, such error on an event will disabled all followings. For TCP
199 streams, this will disable the SPOE for the whole session. For HTTP streams,
200 this will disable it for the transaction (request and response).
201
202 When set, this option bypass this behaviour and only the current event will
203 be ignored.
204
205
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200206option var-prefix <prefix>
207 Define the prefix used when variables are set by an agent.
208
209 Arguments :
210
211 <prefix> is the prefix used to limit the scope of variables set by an
212 agent.
213
214 To avoid conflict with other variables defined by HAProxy, all variables
215 names will be prefixed. By default, the "spoe-agent" name is used. This
216 option can be used to customize it.
217
218 The prefix will be added between the variable scope and its name, separated
219 by a '.'. It may only contain characters 'a-z', 'A-Z', '0-9', '.' and '_', as
220 for variables name. In HAProxy configuration, you need to use this prefix as
221 a part of the variables name. For example, if an agent define the variable
222 "myvar" in the "txn" scope, with the prefix "my_spoe_pfx", then you should
223 use "txn.my_spoe_pfx.myvar" name in your HAProxy configuration.
224
225 An agent will never set new variables at runtime. It can only set new value
226 for existing ones.
227
228
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200229timeout hello <timeout>
230 Set the maximum time to wait for an agent to receive the AGENT-HELLO frame.
Christopher Fauletf7a30922016-11-10 15:04:51 +0100231 It is applied on the stream that handle the connection with the agent.
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200232
233 Arguments :
234 <timeout> is the timeout value specified in milliseconds by default, but
235 can be in any other unit if the number is suffixed by the unit,
236 as explained at the top of this document.
237
238 This timeout is an applicative timeout. It differ from "timeout connect"
239 defined on backends.
240
241
242timeout idle <timeout>
Christopher Fauletf7a30922016-11-10 15:04:51 +0100243 Set the maximum time to wait for an agent to close an idle connection. It is
244 applied on the stream that handle the connection with the agent.
245
246 Arguments :
247 <timeout> is the timeout value specified in milliseconds by default, but
248 can be in any other unit if the number is suffixed by the unit,
249 as explained at the top of this document.
250
251
252timeout processing <timeout>
253 Set the maximum time to wait for a stream to process an event, i.e to acquire
254 a stream to talk with an agent, to encode all messages, to send the NOTIFY
255 frame, to receive the corrsponding acknowledgement and to process all
256 actions. It is applied on the stream that handle the client and the server
257 sessions.
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200258
259 Arguments :
260 <timeout> is the timeout value specified in milliseconds by default, but
261 can be in any other unit if the number is suffixed by the unit,
262 as explained at the top of this document.
263
264
265use-backend <backend>
266 Specify the backend to use. It must be defined.
267
268 Arguments :
269 <backend> is the name of a valid "backend" section.
270
271
2722.3. "spoe-message" section
273----------------------------
274
275To offload the stream processing, SPOE will send messages with specific
276information at a specific moment in the stream life and will wait for
277corresponding replies to know what to do.
278
279
280spoe-message <name>
281 Create a new SPOE message with the name <name>.
282
283 Arguments :
284 <name> is the name of the SPOE message.
285
286 Here you define a message that can be referenced in a "spoe-agent"
287 section. Following keywords are supported :
288 - args
289 - event
290
291 See also: "spoe-agent" section.
292
293
294args [name=]<sample> ...
295 Define arguments passed into the SPOE message.
296
297 Arguments :
298 <sample> is a sample expression.
299
300 When the message is processed, if a sample expression is not available, it is
301 set to NULL. Arguments are processed in their declaration order and added in
302 the message in that order. It is possible to declare named arguements.
303
304 For example:
305 args frontend=fe_id src dst
306
307
308event <name>
309 Set the event that triggers sending of the message.
310
311 Argument :
312 <name> is the event name.
313
314 Supported events are:
315 - on-client-session
316 - on-server-connectiob
317 - on-frontend-tcp-request
318 - on-backend-tcp-request
319 - on-tcp-response
320 - on-frontend-http-request
321 - on-backend-http-request
322 - on-http-response
323
324 See section 3.5 about Events.
325
3262.4. Example
327-------------
328
329Here is a simple but complete example that sends client-ip address to a ip
330reputation service. This service can set the variable "ip_score" which is an
331integer between 0 and 100, indicating its reputation (100 means totally safe
332and 0 a blacklisted IP with no doubt).
333
334 ###
335 ### HAProxy configuration
336 frontend www
337 mode http
338 bind *:80
339
340 filter spoe engine ip-reputation config spoe-ip-reputation.conf
341
342 # Reject connection if the IP reputation is under 20
343 tcp-request content reject if { var(sess.iprep.ip_score) -m int lt 20 }
344
345 default_backend http-servers
346
347 backend http-servers
348 mode http
349 server http A.B.C.D:80
350
351 backend iprep-servers
352 mode tcp
353 balance roundrobin
354
355 timeout connect 5s # greater than hello timeout
356 timeout server 3m # greater than idle timeout
357
358 server iprep1 A1.B1.C1.D1:12345
359 server iprep2 A2.B2.C2.D2:12345
360
361 ####
362 ### spoe-ip-reputation.conf
363 [ip-reputation]
364
365 spoe-agent iprep-agent
366 messages get-ip-reputation
367
368 option var-prefix iprep
369
Christopher Faulet03a34492016-11-19 16:47:56 +0100370 timeout hello 2s
371 timeout idle 2m
372 timeout processing 10ms
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200373
374 use-backend iprep-servers
375
376 spoe-message get-ip-reputation
377 args ip=src
378 event on-client-session
379
380
3813. SPOP specification
382----------------------
383
3843.1. Data types
385----------------
386
387Here is the bytewise representation of typed data:
388
389 TYPED-DATA : <TYPE:4 bits><FLAGS:4 bits><DATA>
390
391Supported types and their representation are:
392
393 TYPE | ID | DESCRIPTION
394 -----------------------------+-----+----------------------------------
395 NULL | 0 | NULL : <0>
396 Boolean | 1 | BOOL : <1+FLAG>
397 32bits signed integer | 2 | INT32 : <2><VALUE:varint>
398 32bits unsigned integer | 3 | UINT32 : <3><VALUE:varint>
399 64bits signed integer | 4 | INT64 : <4><VALUE:varint>
400 32bits unsigned integer | 5 | UNIT64 : <5><VALUE:varint>
401 IPV4 | 6 | IPV4 : <6><STRUCT IN_ADDR:4 bytes>
402 IPV6 | 7 | IPV6 : <7><STRUCT IN_ADDR6:16 bytes>
403 String | 8 | STRING : <8><LENGTH:varint><BYTES>
404 Binary | 9 | BINARY : <9><LENGTH:varint><BYTES>
405 10 -> 15 unused/reserved | - | -
406 -----------------------------+-----+----------------------------------
407
408Variable-length integer (varint) are encoded using Peers encoding:
409
410
411 0 <= X < 240 : 1 byte (7.875 bits) [ XXXX XXXX ]
412 240 <= X < 2288 : 2 bytes (11 bits) [ 1111 XXXX ] [ 0XXX XXXX ]
413 2288 <= X < 264432 : 3 bytes (18 bits) [ 1111 XXXX ] [ 1XXX XXXX ] [ 0XXX XXXX ]
414 264432 <= X < 33818864 : 4 bytes (25 bits) [ 1111 XXXX ] [ 1XXX XXXX ]*2 [ 0XXX XXXX ]
415 33818864 <= X < 4328786160 : 5 bytes (32 bits) [ 1111 XXXX ] [ 1XXX XXXX ]*3 [ 0XXX XXXX ]
416 ...
417
418For booleans, the value (true or false) is the first bit in the FLAGS
419bitfield. if this bit is set to 0, then the boolean is evaluated as false,
420otherwise, the boolean is evaluated as true.
421
4223.2. Frames
423------------
424
425Exchange between HAProxy and agents are made using FRAME packets. All frames
426must be prefixed with their size encoded on 4 bytes in network byte order:
427
428 <FRAME-LENGTH:4 bytes> <FRAME>
429
430A frame always starts with its type, on one byte, followed by metadata
431containing flags, on 4 bytes and a two variable-length integer representing the
432stream identifier and the frame identifier inside the stream:
433
434 FRAME : <FRAME-TYPE:1 byte> <METADATA> <FRAME-PAYLOAD>
435 METADATA : <FLAGS:4 bytes> <STREAM-ID:varint> <FRAME-ID:varint>
436
437Then comes the frame payload. Depending on the frame type, the payload can be
438of three types: a simple key/value list, a list of messages or a list of
439actions.
440
441 FRAME-PAYLOAD : <LIST-OF-MESSAGES> | <LIST-OF-ACTIONS> | <KV-LIST>
442
443 LIST-OF-MESSAGES : [ <MESSAGE-NAME> <NB-ARGS:1 byte> <KV-LIST> ... ]
444 MESSAGE-NAME : <STRING>
445
446 LIST-OF-ACTIONS : [ <ACTION-TYPE:1 byte> <NB-ARGS:1 byte> <ACTION-ARGS> ... ]
447 ACTION-ARGS : [ <TYPED-DATA>... ]
448
449 KV-LIST : [ <KV-NAME> <KV-VALUE> ... ]
450 KV-NAME : <STRING>
451 KV-VALUE : <TYPED-DATA>
452
453 FLAGS : 0 1-31
454 +---+-----------+
455 | F| |
456 | I| RESERVED |
457 | N| |
458 +--+------------+
459
460 FIN: Indicates that this is the final payload fragment. The first fragment
461 may also be the final fragment.
462
463Frames cannot exceed a maximum size negociated between HAProxy and agents
464during the HELLO handshake. Most of time, payload will be small enough to send
465it in one frame. But when supported by the peer, it will be possible to
466fragment huge payload on many frames. This ability is announced during the
467HELLO handshake and it can be asynmetric (supported by agents but not by
468HAProxy or the opposite). The following rules apply to fragmentation:
469
470 * An unfragemnted payload consists of a single frame with the FIN bit set.
471
472 * A fragemented payload consists of several frames with the FIN bit clear and
473 terminated by a single frame with the FIN bit set. All these frames must
474 share the same STREAM-ID and FRAME-ID. And, of course, the FRAME-TYPE must
475 be the same.
476
477Beside the support of fragmented payload by a peer, some payload must not be
478fragmented. See below for details.
479
480IMPORTANT : The maximum size supported by peers for a frame must be greater or
481equal to 256 bytes.
482
4833.2.1. Frame capabilities
484--------------------------
485
486Here are the list of official capabilities that HAProxy and agents can support:
487
488 * fragmentation: This is the abaility for a peer to support fragmented
489 payload in received frames.
490
491Unsupported or unknown capabilities are silently ignored, when possible.
492
4933.2.2. Frame types overview
494----------------------------
495
496Here are types of frame supported by SPOE. Frames sent by HAProxy come first,
497then frames sent by agents :
498
499 TYPE | ID | DESCRIPTION
500 -----------------------------+-----+-------------------------------------
501 HAPROXY-HELLO | 1 | Sent by HAProxy when it opens a
502 | | connection on an agent.
503 | |
504 HAPROXY-DISCONNECT | 2 | Sent by HAProxy when it want to close
505 | | the connection or in reply to an
506 | | AGENT-DISCONNECT frame
507 | |
508 NOTIFY | 3 | Sent by HAProxy to pass information
509 | | to an agent
510 -----------------------------+-----+-------------------------------------
511 AGENT-HELLO | 101 | Reply to a HAPROXY-HELLO frame, when
512 | | the connection is established
513 | |
514 AGENT-DISCONNECT | 102 | Sent by an agent just before closing
515 | | the connection
516 | |
517 ACK | 103 | Sent to acknowledge a NOTIFY frame
518 -----------------------------+-----+-------------------------------------
519
520Unknown frames may be silently skipped.
521
5223.2.3. Workflow
523----------------
524
525 * Successful HELLO handshake:
526
527 HAPROXY AGENT SRV
528 | HAPROXY-HELLO |
Christopher Fauletba7bc162016-11-07 21:07:38 +0100529 | (healthcheck: false) |
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200530 | --------------------------> |
531 | |
532 | AGENT-HELLO |
533 | <-------------------------- |
534 | |
535
Christopher Fauletba7bc162016-11-07 21:07:38 +0100536 * Successful HELLO healthcheck:
537
538 HAPROXY AGENT SRV
539 | HAPROXY-HELLO |
540 | (healthcheck: true) |
541 | --------------------------> |
542 | |
543 | AGENT-HELLO + close() |
544 | <-------------------------- |
545 | |
546
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200547
548 * Error encountered by agent during the HELLO handshake:
549
550 HAPROXY AGENT SRV
551 | HAPROXY-HELLO |
552 | --------------------------> |
553 | |
554 | DISCONNECT + close() |
555 | <-------------------------- |
556 | |
557
558 * Error encountered by HAProxy during the HELLO handshake:
559
560 HAPROXY AGENT SRV
561 | HAPROXY-HELLO |
562 | --------------------------> |
563 | |
564 | AGENT-HELLO |
565 | <-------------------------- |
566 | |
567 | DISCONNECT |
568 | --------------------------> |
569 | |
570 | DISCONNECT + close() |
571 | <-------------------------- |
572 | |
573
574 * Notify / Ack exchange:
575
576 HAPROXY AGENT SRV
577 | NOTIFY |
578 | --------------------------> |
579 | |
580 | ACK |
581 | <-------------------------- |
582 | |
583
584 * Connection closed by haproxy:
585
586 HAPROXY AGENT SRV
587 | DISCONNECT |
588 | --------------------------> |
589 | |
590 | DISCONNECT + close() |
591 | <-------------------------- |
592 | |
593
594 * Connection closed by agent:
595
596 HAPROXY AGENT SRV
597 | DISCONNECT + close() |
598 | <-------------------------- |
599 | |
600
6013.2.4. Frame: HAPROXY-HELLO
602----------------------------
603
604This frame is the first one exchanged between HAProxy and an agent, when the
605connection is established. The payload of this frame is a KV-LIST. It cannot be
606fragmented. STREAM-ID and FRAME-ID are must be set 0.
607
608Following items are mandatory in the KV-LIST:
609
610 * "supported-versions" <STRING>
611
612 Last SPOP major versions supported by HAProxy. It is a comma-separated list
613 of versions, following the format "Major.Minor". Spaces must be ignored, if
614 any. When a major version is announced by HAProxy, it means it also support
615 all previous minor versions.
616
617 Example: "2.0, 1.5" means HAProxy supports SPOP 2.0 and 1.0 to 1.5
618
619 * "max-frame-size" <UINT32>
620
621 This is the maximum size allowed for a frame. The HAPROXY-HELLO frame must
622 be lower or equal to this value.
623
624 * "capabilities" <STRING>
625
626 This a comma-separated list of capabilities supported by HAProxy. Spaces
627 must be ignored, if any.
628
Christopher Fauletba7bc162016-11-07 21:07:38 +0100629Following optional items can be added in the KV-LIST:
630
631 * "healthcheck" <BOOLEAN>
632
633 If this item is set to TRUE, then the HAPROXY-HELLO frame is sent during a
634 SPOE health check. When set to FALSE, this item can be ignored.
635
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200636To finish the HELLO handshake, the agent must return an AGENT-HELLO frame with
637its supported SPOP version, the lower value between its maximum size allowed
638for a frame and the HAProxy one and capabilities it supports. If an error
639occurs or if an incompatibility is detected with the agent configuration, an
640AGENT-DISCONNECT frame must be returned.
641
6423.2.5. Frame: AGENT-HELLO
643--------------------------
644
645This frame is sent in reply to a HAPROXY-HELLO frame to finish a HELLO
646handshake. As for HAPROXY-HELLO frame, STREAM-ID and FRAME-ID are also set
6470. The payload of this frame is a KV-LIST and it cannot be fragmented.
648
649Following items are mandatory in the KV-LIST:
650
651 * "version" <STRING>
652
653 This is the SPOP version the agent supports. It must follow the format
654 "Major.Minor" and it must be lower or equal than one of major versions
655 announced by HAProxy.
656
657 * "max-frame-size" <UINT32>
658
659 This is the maximum size allowed for a frame. It must be lower or equal to
660 the value in the HAPROXY-HELLO frame. This value will be used for all
661 subsequent frames.
662
663 * "capabilities" <STRING>
664
665 This a comma-separated list of capabilities supported by agent. Spaces must
666 be ignored, if any.
667
668At this time, if everything is ok for HAProxy (supported version and valid
669max-frame-size value), the HELLO handshake is successfully completed. Else,
670HAProxy sends a HAPROXY-DISCONNECT frame with the corresponding error.
671
Christopher Fauletba7bc162016-11-07 21:07:38 +0100672If "healthcheck" item was set to TRUE in the HAPROXY-HELLO frame, the agent can
673safely close the connection without DISCONNECT frame. In all cases, HAProxy
674will close the connexion at the end of the health check.
675
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +02006763.2.6. Frame: NOTIFY
677---------------------
678
679Information are sent to the agents inside NOTIFY frames. These frames are
680attached to a stream, so STREAM-ID and FRAME-ID must be set. The payload of
681NOTIFY frames is a LIST-OF-MESSAGES and, if supported by agents, it can be
682fragmented.
683
684NOTIFY frames must be acknowledge by agents sending an ACK frame, repeating
685right STREAM-ID and FRAME-ID.
686
6873.2.7. Frame: ACK
688------------------
689
690ACK frames must be sent by agents to reply to NOTIFY frames. STREAM-ID and
691FRAME-ID found in a NOTIFY frame must be reuse in the corresponding ACK
692frame. The payload of ACK frames is a LIST-OF-ACTIONS and, if supported by
693HAProxy, it can be fragmented.
694
6953.2.8. Frame: HAPROXY-DISCONNECT
696---------------------------------
697
698If an error occurs, at anytime, from the HAProxy side, a HAPROXY-DISCONNECT
699frame is sent with information describing the error. HAProxy will wait an
700AGENT-DISCONNECT frame in reply. All other frames will be ignored. The agent
701must then close the socket.
702
703The payload of this frame is a KV-LIST. It cannot be fragmented. STREAM-ID and
704FRAME-ID are must be set 0.
705
706Following items are mandatory in the KV-LIST:
707
708 * "status-code" <UINT32>
709
710 This is the code corresponding to the error.
711
712 * "message" <STRING>
713
714 This is a textual message describing the error.
715
716For more information about known errors, see section "Errors & timeouts"
717
7183.2.9. Frame: AGENT-DISCONNECT
719-------------------------------
720
721If an error occurs, at anytime, from the agent size, a AGENT-DISCONNECT frame
722is sent, with information desribing the error. such frame is also sent in reply
723to a HAPROXY-DISCONNECT. The agent must close the socket just after sending
724this frame.
725
726The payload of this frame is a KV-LIST. It cannot be fragmented. STREAM-ID and
727FRAME-ID are must be set 0.
728
729Following items are mandatory in the KV-LIST:
730
731 * "status-code" <UINT32>
732
733 This is the code corresponding to the error.
734
735 * "message" <STRING>
736
737 This is a textual message describing the error.
738
739For more information about known errors, see section "Errors & timeouts"
740
7413.3. Events & Messages
742-----------------------
743
744Information about streams are sent in NOTIFY frames. You can specify which kind
745of information to send by defining "spoe-message" sections in your SPOE
746configuration file. for each "spoe-message" there will be a message in a NOTIFY
747frame when the right event is triggered.
748
749A NOTIFY frame is sent for an specific event when there is at least one
750"spoe-message" attached to this event. All messages for an event will be added
751in the same NOTIFY frame.
752
753Here is the list of supported events:
754
755 * on-client-session is triggered when a new client session is created.
756 This event is only available for SPOE filters
757 declared in a frontend or a listen section.
758
759 * on-frontend-tcp-request is triggered just before the evaluation of
760 "tcp-request content" rules on the frontend side.
761 This event is only available for SPOE filters
762 declared in a frontend or a listen section.
763
764 * on-backend-tcp-request is triggered just before the evaluation of
765 "tcp-request content" rules on the backend side.
766 This event is skipped for SPOE filters declared
767 in a listen section.
768
769 * on-frontend-http-request is triggered just before the evaluation of
770 "http-request" rules on the frontend side. This
771 event is only available for SPOE filters declared
772 in a frontend or a listen section.
773
774 * on-backend-http-request is triggered just before the evaluation of
775 "http-request" rules on the backend side. This
776 event is skipped for SPOE filters declared in a
777 listen section.
778
779 * on-server-session is triggered when the session with the server is
780 established.
781
782 * on-tcp-response is triggered just before the evaluation of
783 "tcp-response content" rules.
784
785 * on-http-response is triggered just before the evaluation of
786 "http-response" rules.
787
788
789The stream processing will loop on these events, when triggered, waiting the
790agent reply.
791
7923.4. Actions
793-------------
794
795An agent must acknowledge each NOTIFY frame by sending the corresponding ACK
796frame. Actions can be added in these frames to dynamically take action on the
797processing of a stream.
798
799Here is the list of supported actions:
800
801 * set-var set the value for an existing variable. 3 arguments must be
802 attached to this action: the variable scope (proc, sess, txn,
803 req or req), the variable name (a string) and its value.
804
805 ACTION-SET-VAR : <SET-VAR:1 byte><NB-ARGS:1 byte><VAR-SCOPE:1 byte><VAR-NAME><VAR-VALUE>
806
807 SET-VAR : <1>
808 NB-ARGS : <3>
809 VAR-SCOPE : <PROCESS> | <SESSION> | <TRANSACTION> | <REQUEST> | <RESPONSE>
810 VAR-NAME : <STRING>
811 VAR-VALUE : <TYPED-DATA>
812
813 PROCESS : <0>
814 SESSION : <1>
815 TRANSACTION : <2>
816 REQUEST : <3>
817 RESERVED : <4>
818
819 * unset-var unset the value for an existing variable. 2 arguments must be
820 attached to this action: the variable scope (proc, sess, txn,
821 req or req) and the variable name (a string).
822
823 ACTION-UNSET-VAR : <SET-VAR:1 byte><NB-ARGS:1 byte><VAR-SCOPE:1 byte><VAR-NAME>
824
825 SET-VAR : <1>
826 NB-ARGS : <3>
827 VAR-SCOPE : <PROCESS> | <SESSION> | <TRANSACTION> | <REQUEST> | <RESPONSE>
828 VAR-NAME : <STRING>
829
830 PROCESS : <0>
831 SESSION : <1>
832 TRANSACTION : <2>
833 REQUEST : <3>
834 RESERVED : <4>
835
836
837NOTE: Name of the variables will be automatically prefixed by HAProxy to avoid
838 name clashes with other variables used in HAProxy. Moreover, unknown
839 variable will be silently ignored.
840
8413.5. Error & timeouts
842----------------------
843
844Here is the list of all known errors:
845
846 STATUS CODE | DESCRIPTION
847 ----------------+--------------------------------------------------------
848 0 | normal (no error occurred)
849 1 | I/O error
850 2 | A timeout occurred
851 3 | frame is too big
852 4 | invalid frame received
853 5 | version value not found
854 6 | max-frame-size value not found
855 7 | capabilities value not found
856 8 | unsupported version
857 9 | max-frame-size too big or too small
858 99 | an unknown error occurrde
859 ----------------+--------------------------------------------------------
860
861An agent can define its own errors using a not yet assigned status code.
862
Christopher Fauletea62c2a2016-11-14 10:54:21 +0100863IMPORTANT NOTE: By default, for a specific stream, when an abnormal/unexpected
864 error occurs, the SPOE is disabled for all the transaction. So
865 if you have several events configured, such error on an event
866 will disabled all followings. For TCP streams, this will
867 disable the SPOE for the whole session. For HTTP streams, this
868 will disable it for the transaction (request and response).
869 See 'option continue-on-error' to bypass this limitation.
Christopher Fauletf7e4e7e2016-10-27 22:29:49 +0200870
871To avoid a stream to wait infinitly, you must carefully choose the
872acknowledgement timeout. In most of cases, it will be quiet low. But it depends
873on the responsivness of your service.
874
875You must also choose idle timeout carefully. Because connection with your
876service depends on the backend configuration used by the SPOA, it is important
877to use a lower value for idle timeout than the server timeout. Else the
878connection will be closed by HAProxy. The same is true for hello timeout. You
879should choose a lower value than the connect timeout.
880
881
882/*
883 * Local variables:
884 * fill-column: 79
885 * End:
886 */