Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse HTTP port for WebSocket #272

Open
fregante opened this issue Mar 19, 2023 · 1 comment
Open

Reuse HTTP port for WebSocket #272

fregante opened this issue Mar 19, 2023 · 1 comment

Comments

@fregante
Copy link
Owner

fregante commented Mar 19, 2023

Findings:

  • There's no need to create a new WebSocket server for every connection
  • WebSocket servers can live on the same connection as HTTP servers

Changes suggested:

  • Have the HTTP server return a static response: {ProtocolVersion: 1, WebSocketPort: 4001} (the port is still user-configurable)
  • Move the connection logic behind the WebSocket instead of the HTTP server, because in the future the browser extension will be able to skip the HTTP request

This change is backwards-compatible in editor extensions, it can already be seen in the new VS Code extension: https://github.com/fregante/GhostText-for-VSCode/blob/17a6d24f066aef98c2561b8690592c08e5c8c6ff/source/extension.ts#L120-L122

I think the ACME plugin has also been doing this for years: https://github.com/fhs/Ghost/blob/aaff3cd0ec26f69a7f6bc59e8a419fafa5d7aa6d/main.go#L80

@fregante
Copy link
Owner Author

fregante commented Mar 19, 2023

cc @subnut if you want to pick this up

fregante added a commit to GhostText/GhostText-for-SublimeText that referenced this issue Mar 24, 2023
but [Errno 48] Address already in use

For fregante/GhostText#272
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant