Skip to content

Using ClientWebSocket through a proxy #93

@Robert-96

Description

@Robert-96

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions