Closed FossPrime closed 1 year ago
Hey there 👋 Just wanted to inform you that WebSocket support has been added for inter-process communication. This means that you can now have a WebSocket client in one process and a server in another process. I tested your provided chat example and it seems to work as expected. I am closing this issue for now. If you still experience issues, feel free to open a new issue.
Describe the bug
Chat bots, unit tests, DB connections, multi-process optimizations, dependencies and integrations
Describe the bug Trying to connect to a WebSockets server from WebContainers causes a 400 Bad Request error. This happens even when connecting to a Socket.io server hosted in the same WebContainer or other WebContainers in other StackBlitz Sandboxes.
Connecting to WebSockets servers from the browser works normally, as long as CORS is configured. this issue is not about connections from the browser. This issue is exclusively about connecting from WebContainers to WebContainers running WS servers, that is, NOT to external Node.js server. No browser code, baremetal code or external servers are necessary to encounter this issue.
This affects:
Link to the blitz that caused the error
Simplest socket.io example: https://stackblitz.com/edit/sb-ws-bug?file=vite.config.ts,ReadMe.md
Steps to reproduce
npm run dev
Expected behavior
All posted "Chatbot" messages will print to the console.
Actual Behavior
Link to the blitz that caused the error
https://stackblitz.com/edit/sb-ws-bug?file=vite.config.ts,ReadMe.md
Steps to reproduce
Expected behavior
Parity with Local
Screenshots
From reproduction sandbox:
Same code in bare-metal Node.js:
Platform
Additional context
Workarounds
Current workaround is to run the server baremetal if possible, or host it externally in something like CodeSandbox Containers or Kubernetes.