Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ClientWebSocket through a proxy #93

Open
Robert-96 opened this issue Nov 27, 2023 · 0 comments
Open

Using ClientWebSocket through a proxy #93

Robert-96 opened this issue Nov 27, 2023 · 0 comments

Comments

@Robert-96
Copy link

Robert-96 commented Nov 27, 2023

Did anyone manage to use the NativeWebSocket/ClientWebSocket through a proxy?

Basically I tried to set the Proxy property from the ClientWebSocketOptions but the client does't connect to the server. It's giving me a 'Unable to connect to the remote server' error.

Here's my code snippet:

var source = new CancellationTokenSource();
var token = source.Token;

var socket = new ClientWebSocket();
WebRequest.DefaultWebProxy = new WebProxy(proxyUrl, false); // I tried to set the DefaultWebProxy too, but I get the same error 
socket.Options.Proxy = new WebProxy(proxyUrl, false);
                
await socket.ConnectAsync(uri, token);

It works in .NET5 but not in Unity.

Any insights or suggestions on resolving this issue would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant