I am attempting to make use of ClientWebSocket
in Unity with a proxy like this:
var supply = new CancellationTokenSource();
var token = supply.Token;
var socket = new ClientWebSocket();
socket.Choices.Proxy = new WebProxy(proxyUrl, false);
await socket.ConnectAsync(uri, token);
But it surely’s giving me a ‘Unable to connect with the distant server’ error. Any concepts on what is perhaps going unsuitable?
I additionally tried to implement IWebProxy
like this:
public class WebSocketProxy : IWebProxy
{
non-public ICredentials iCredentials;
non-public Uri webProxyUri;
public WebSocketProxy(Uri proxyUri)
{
webProxyUri = proxyUri;
}
public ICredentials Credentials
{
get
{
return iCredentials;
}
set
{
if (iCredentials != worth)
{
iCredentials = worth;
}
}
}
public Uri? GetProxy(Uri destUri)
{
// At all times use the identical proxy.
Debug.Log("GetProxy referred to as");
return webProxyUri;
}
public bool IsBypassed(Uri hostUri)
{
// By no means bypass the proxy.
Debug.Log("IsBypassed referred to as");
return false;
}
}
Nevertheless, primarily based on the logs, it seems that the GetProxy
and IsBypassed
strategies are by no means being referred to as.