question

$$ANON_USER$$ avatar image
0 Votes"
$$ANON_USER$$ asked $$ANON_USER$$ commented

How to persist a websocket connection using ControlChannelTrigger in the background?

Hello, I followed https://docs.microsoft.com/en-us/windows/uwp/networking/network-communications-in-the-background#controlchanneltrigger-with-websockets and create an out-of-process background task using ControlChannelTrigger with MessageWebSocket.

Everything works fine in the foreground, however, if I close the app window, the websocket connection will be killed and no longer receive any message.

I re-opened my app but found registered BackgroundTasks didn't exist any more and I had to register them again.

How can I persist a websocket connection using ControlChannelTrigger in the background?

Thanks!

windows-uwp
· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, Can you provide a minimum runnable demo? This will help us debug and resolve your issue. In addition, maybe this official example provided by Microsoft will help you, it shows how to create a StreamSocket that can still be active outside the application life cycle. Although it is different from WebSocket, the general process is the same and can be used as a reference.

0 Votes 0 ·

Hello, may you please provide further information to help us solve the problem?

0 Votes 0 ·

Yes.
I can provide a minimal repro, but I cannot find a suitable websocket server for now...

0 Votes 0 ·

You can refer to the example of StreamSocket I provided to create another Server project to run locally.

0 Votes 0 ·
Show more comments

0 Answers