Skip to content

Fix GRBL network disconnect with MKS DLC32#274

Merged
knipknap merged 1 commit into
mainfrom
fix/grbl-network-mks-dlc32-disconnect
Jun 4, 2026
Merged

Fix GRBL network disconnect with MKS DLC32#274
knipknap merged 1 commit into
mainfrom
fix/grbl-network-mks-dlc32-disconnect

Conversation

@knipknap

@knipknap knipknap commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #273

  • Disables client-side WebSocket ping/pong keepalive by setting ping_interval=None in websockets.connect()

Problem

The MKS DLC32 board's WebSocket server sends incorrectly masked response frames. When the websockets library sends its default keepalive ping (every 20 seconds), the server's response triggers a protocol error:

> CLOSE 1002 (protocol error) incorrect masking

This causes the connection to drop every 20-30 seconds, making machine controls gray out until auto-reconnect completes.

Why this is safe

The client-side ping is redundant because:

  • The MKS DLC32 server already sends its own WebSocket pings (< PING '' [0 bytes])
  • The HTTP transport polls status every 0.5 seconds, providing a secondary keepalive
  • For other GRBL network devices that don't send pings, the HTTP polling still ensures connection liveness is monitored

Testing

  • Verified with flake8 lint (no issues)
  • Existing test suite references GrblNetworkDriver in test_machine.py (no new tests needed for a one-line transport parameter change)

Disable client-side WebSocket ping/pong keepalive to prevent
protocol errors with MKS DLC32 boards. The board's WebSocket
server sends incorrectly masked responses after receiving a ping,
causing the websockets library to close the connection every
20-30 seconds.

This is safe because:
- The server already sends its own pings
- HTTP polling provides a secondary keepalive at 0.5s intervals
@knipknap
knipknap merged commit de5896f into main Jun 4, 2026
29 checks passed
@knipknap
knipknap deleted the fix/grbl-network-mks-dlc32-disconnect branch June 4, 2026 20:16
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.

Connection issue with GRBL Network mode and MKS DLC32

1 participant