feat: Windows TCP fallback for intercom broker#27
Open
guvengursel wants to merge 1 commit into
Open
Conversation
Windows named pipes (\.\pipe\) may be blocked by security policy
or antivirus, returning EACCES. This adds automatic TCP fallback:
- paths.ts: auto-detect Windows → use TCP port 19315 instead of named pipe
- broker.ts: listen on TCP {port, host} when path is numeric
- client.ts: connect via TCP when path is numeric
- spawn.ts: health-check via TCP when path is numeric
Also adds port file persistence (broker.port) for discovery.
The TCP mode is ONLY activated on Windows by default. Unix systems
continue to use named pipes / Unix domain sockets unchanged.
Environment variable PI_INTERCOM_TCP=1 can force TCP on any platform.
Tested: broker starts and client connects successfully on Windows.
Cross-session intercom messaging works end-to-end.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows, named pipes (
\\.\pipe\) may be blocked by security policy or antivirus software, returningEACCES. This makes the Pi intercom broker completely non-functional on affected Windows machines.Error Observed
Root cause:
net.Server.listen('\\.\pipe\pi-intercom-...')throwsEACCESdue to Windows security restrictions on named pipe creation.Solution
Add automatic TCP fallback when Windows is detected:
paths.ts— Onplatform === 'win32', returns a TCP port number (19315) instead of a named pipe path. Adds helper functions:isTcpMode(),parseTcpPort(),writeBrokerPort(),readBrokerPort().broker.ts— When socket path is numeric (TCP mode), listens on{port, host: '127.0.0.1'}instead of a pipe path.client.ts— When socket path is numeric, connects vianet.connect({port, host})instead ofnet.connect(pipePath).spawn.ts— Health check uses TCP connection when in TCP mode.The framing protocol (length-prefixed JSON) is unchanged — only the transport layer differs.
Behavior
Environment variable
PI_INTERCOM_TCP=1can force TCP on any platform.Testing
npm installfor tsx dependency is required after fresh install