Forge Custom UI Websocket

Hi, I have a question. I implemented a websocket connection inside my custom ui frontend and when a function is run or mutating a state to a reactive object, the iframe seems to be reloaded. The reload caused the function inside the switch case not to run. Also another observation, when running an async function during onmessage event, the iframe reloads and cuts off the running function. If you used websocket like me, please help.

Hi Tristan,

Can you tell me a little bit more about what you’re trying to achieve using a websocket connection? I’m not sure that this would be the best approach given the Forge architecture, so perhaps with a bit more information we might be able to suggest some other way to achieve your desired outcome.

Cheers!
Mel

2 Likes

I Just found out that the cause for the iframe to reload is the async function inside the switch case and found the fix where making the socket onmessage function async and await a function call inside the switch case. But thank you for the response