New Transparent capture is in preview. Record every app's traffic with no proxy configuration, on Windows, macOS and Linux. Learn more

isWebSocketFilter Filter

Select WebSocket exchanges by detecting the HTTP Upgrade handshake, so you can apply actions to bidirectional channels only.

isWebSocketFilter is the dedicated selector for WebSocket exchanges in a Fluxzy rule. It looks at the standard HTTP Upgrade handshake and matches every session that asks to be promoted to the WebSocket protocol. Use it whenever you need to act on bidirectional channels and leave regular request and response traffic untouched.

When to use this filter

Reach for isWebSocketFilter when a rule should only apply to WebSocket sessions, identified by the standard Upgrade: websocket handshake. WebSockets behave quite differently from plain request and response exchanges, so isolating them in your rule pipeline keeps things predictable.

Typical situations:

  • Tagging every WS exchange so they are easy to find in the Fluxzy capture view.
  • Logging the URL of opened channels to a dedicated file for offline analysis.
  • Blocking new WebSocket sessions while keeping regular HTTP traffic intact.

The filter evaluates on the requestHeaderReceivedFromClient scope, so the Upgrade header is already parsed when it fires. Combine it with hostFilter or pathFilter if you only care about WebSocket traffic to a specific endpoint.

Real world examples

Tag every WebSocket exchange

Apply a tag to all WS sessions so they stand out in the Fluxzy UI and can be filtered later for review.

rules:
- filter:
    typeKind: IsWebSocketFilter
  actions:
  - typeKind: ApplyTagAction
    tag:
      value: websocket

Log opened WebSocket channels to a file

Append the URL of each opened WS channel to a dedicated log file so you can audit which endpoints clients connect to.

rules:
- filter:
    typeKind: IsWebSocketFilter
  actions:
  - typeKind: FileAppendAction
    filename: /var/log/fluxzy/ws-channels.log
    text: "{{exchange.url}}"

Reject WebSocket traffic to a banned host

Block new WS sessions targeting a specific host while letting its regular HTTP endpoints continue to work. Useful when you want to disable a real time feature temporarily.

rules:
- filter:
    typeKind: FilterCollection
    children:
    - typeKind: IsWebSocketFilter
    - typeKind: HostFilter
      pattern: realtime.example.com
  actions:
  - typeKind: RejectWithStatusCodeAction
    statusCode: 403

Reference

isWebSocketFilter

Description

Select websocket exchange.

Evaluation scope

Evaluation scope defines the timing where this filter will be applied.

requestHeaderReceivedFromClient This scope occurs the moment fluxzy parsed the request header receiveid from client

YAML configuration name

isWebSocketFilter

Settings

This filter has no specific characteristic

The following table describes the customizable properties available for this filter:

Property Type Description DefaultValue
inverted boolean Negate the filter result false

Example of usage

The following examples apply a comment to the filtered exchange

Select websocket exchange.

rules:
- filter:
    typeKind: IsWebSocketFilter
  actions:
  - typeKind: ApplyCommentAction
    comment: filter was applied

.NET reference

View definition of IsWebSocketFilter for .NET integration.

See also

This filter has no related filter

Frequently asked questions

How does isWebSocketFilter detect a WebSocket session?

It checks the request Upgrade header. Any value of websocket triggers a match. The Connection header and the Sec-WebSocket-Key are not required, although a real client always sends them.

Does it match wss (WebSocket over TLS)?

Yes. wss is a WebSocket session inside a TLS tunnel. The filter matches on the Upgrade handshake regardless of whether the transport is plain or encrypted. Combine with isSecureFilter to distinguish.

Can I match non-WebSocket exchanges?

Yes. Set inverted: true to select every regular HTTP exchange that is not a WebSocket upgrade.

Will the filter let me inspect WebSocket frames?

Not directly. isWebSocketFilter only selects the session. To capture and review individual frames use captureSessionAction or one of the inspection features in the Fluxzy UI.

Learn more about Fluxzy rules