Reputation: 5515
I am trying to make a background task for a UWP app. The task should be triggered by packets from a web socket connection.
I have tested the web socket and it works as expected.
For the background task to work, according to the Microsoft tutorial on background networking (Network communications in the background), a ControlChannelTrigger
must be instantiated and the channel.UsingTransport(socket)
method must be called. Then socket.ConnectAsync(...)
should be called.
However, when calling socket.ConnectAsync(...)
after channel.UsingTransport(socket)
, the socket.ConnectAsync(...)
method throws an exception with the following message.
Exception from HRESULT: 0x80072F75
When called without channel.UsingTransport(socket)
, the connection is established without problems.
In order to use the socket in a background task, I must establish the connection after calling channel.UsingTransport(socket)
.
Can anyone shed some light on why this error might be occurring?
Upvotes: 0
Views: 1016
Reputation: 3808
Please don't install the IIS server on the same device and use localhost to connect the server. See network isolation topic. When using the server in official WebSocket sample , you can try to copy the server folder and its subfolder to another computer and run the server scripts, then you can connect the server with a IP address such as:
Server uri: ws://xxx.xx.xx.xx/WebSocketSample/echowebsocket.ashx
Besides, please have a try to test the ControlChannelTrigger StreamWebSocket sample.
Also see the Note part in the sample:
When used with the supplied scripts, this Windows Store app sample communicates with another process (IIS server which is a desktop app) on the same machine over loopback for demonstration purposes only. A Windows Store app that communicates over loopback to another process that represents a Windows Store app is not allowed and such apps will not pass Store validation. For more information, see How to configure network isolation capabilities.
Upvotes: 1