混音 - 如何向我的项目添加Websocket
我在remix.run上启动了一个独立堆栈项目,我想添加websocket.io。 我想将来部署以净化。您能帮我吗,我是新来的,真的不知道该怎么办。
我发现可以使用“ Express”选项启动独立堆栈项目,但我不知道它是否与Netlify兼容。
I started a indie stack project on remix.run and I would like to add websocket.io.
I would like to deploy in the future to Netlify. Could you please help me, I am new and do not really know what to do.
I found that it is possible to start a indie stack project with the "express" option but I do not know if it will be compatible with netlify.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知, socket.io 需要一个长期运行的服务器。诸如NetLify功能之类的无服务器环境将无法正常工作。有多种方法可以在AWS lambda上建立WebSocket连接,但我不确定socket.io支持此类配置。 Netlify和Vercel肯定不会(此时)。
目前,将REMIX与Express适配器一起使用。选择一个与Express一起使用的堆栈,然后您可以像在任何其他Express Server和React Client Project上一样简单地集成socket.io。
您可以找到一个 with socket.io示例example.io示例 Remix GitHub存储库的示例文件夹。
有一个正在进行的讨论关于Remix中的本机WEBSOCKECT。但是,由于Websockets在大多数无服务器环境中都无法正常工作,因此WebSockets将其变成混音不可能。
但是,似乎Remix团队正在努力将服务器范围的事件(SSE)引入其Fetch API。 SSE可以作为Websocket的替代方案。也许这可能是未来读者的替代方法。您可以找到讨论在这里。
As far as I know, socket.io requires a long-running server. A serverless environment such as Netlify functions won't work. There are ways to make websocket connections on AWS Lambda but I am not sure socket.io supports such configurations. Netlify and Vercel for sure don't (at this point).
For now, use Remix with the express adapter. Pick a stack that works with express and then you can simply integrate socket.io like you would on any other express server and React client project.
You can find a great Remix with socket.io example in the examples folder of Remix GitHub repository.
There is an ongoing discussion about native websocket support in Remix. However, since websockets won't work on most serverless environments, it's unlikely at this moment that websockets will make it into Remix.
However, it seems like the Remix team is working on introducing Server-Sent-Events (SSE) to its fetch API. SSE can work as an alternative to websockets. Maybe that could be an alternative for future readers. You can find the discussion here.