theelims / ESP32-sveltekit

A simple and extensible framework for ESP32 based IoT projects with a feature-rich, beautiful, and responsive front-end build with Sveltekit, Tailwind CSS and DaisyUI. This is a project template to get you started in no time with a fully integrated build chain.
https://theelims.github.io/ESP32-sveltekit/
Other
90 stars 15 forks source link

Minimize number of parallel sockets #29

Closed theelims closed 2 months ago

theelims commented 3 months ago

Right now the Lightstate Demo uses 2 sockets for SSE and WS and need a 3rd socket to update the HTTP pages. PsychicHttp limits the available sockets to 5 crippling the number of devices available for concurrent connections.

  1. Create a UnifiedWebSocketServerEndpoint to use only one socket per frontend connection
  2. Merge the NotificationEvents (SSE) into this UnifiedWebSocketServerEndpoint
  3. Use this additionally as an endpoint for the lightstate demo to show both usecases
theelims commented 2 months ago

@runeharlyk I was looking around your github repos and found your work on the sockets, as well your previous ESP32 svelte template. Maybe we can sit down and discuss a couple of things round these two. Especially I am interested in your experience with that single file vite plugin. Does this work for SvelteKit? Right now the frontend creates ~64 endpoints. Each endpoint consumes a few bytes in heap. Thus larger apps with a heavier frontend put a lot of pressure on the available heap and it would be preferable to reduced the number endpoints significantly.

runeharlyk commented 2 months ago

Very cool, I would definitely want to discuss them.

As for the single-file-plugin - It only works with single entry apps as the plugin uses the inlineDynamic option which is not supported by rollup if there are multiple entries (See this issue ). That is the reason my simple template only uses svelte with svelte-router. But maybe we can build a new plugin that get around this restriction.

theelims commented 2 months ago

Would you be open for other communication channels like discord? My handle is the same as on github.

I would like to understand how you do you socket implementation. From my point of view it should replace SSE and be available as a further endpoint (with the same mechanic and API as the other endpoints) for custom services.

The other topic seems to be tough nut to crack open: https://github.com/sveltejs/kit/issues/3882

runeharlyk commented 2 months ago

I tried adding you, but it seem like i cant send you a friend request. Maybe you can try adding me. My handles also match.

theelims commented 2 months ago

I did sent you a request and also activated that everybody can send my a friend request.

theelims commented 2 months ago

This issue is closed and a Event Socket System based on a single WebSocket connection will be included in the next release.