Skip to content

Conversation

undostres321
Copy link

Closes #4593

What?

This PR adds support for sending WebSocket ping frames with application data, as specified in RFC 6455 section 5.5.2. The implementation updates both:

  • Standard WebSocket implementation (k6/ws)
  • Experimental WebSocket implementation (k6/experimental/websockets)

The WebSocket ping() method now accepts an optional string parameter for application data. Examples:

// Send a regular ping without application data
socket.ping();

// Send a ping with application data
socket.ping("application-data");

Why?

RFC 6455 section 5.5.2 states that ping frames MAY include application data. This implementation:

  • Enhances the WebSocket API to fully comply with the WebSocket protocol specification
  • Allows users to leverage ping frames for custom application-level keep-alive mechanisms
  • Maintains backward compatibility with existing code while adding new functionality
  • Properly handles both RTT metrics tracking and application data separation

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

Issue #4593: Add ability to ping send Application data per RFC 6455

@undostres321 undostres321 requested a review from a team as a code owner October 2, 2025 23:10
@undostres321 undostres321 requested review from ankur22 and mstoykov and removed request for a team October 2, 2025 23:10
@undostres321 undostres321 temporarily deployed to azure-trusted-signing October 14, 2025 06:50 — with GitHub Actions Inactive
@undostres321 undostres321 temporarily deployed to azure-trusted-signing October 14, 2025 06:53 — with GitHub Actions Inactive
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

Successfully merging this pull request may close these issues.

Add ability to ping send Application data

1 participant