Proxy support

Jun 25, 2013 at 3:58 PM
Hello,

Is there any examples of how to implement proxy configuration using WebSocket4Net?
I know there is a method to set the proxy in the WebSocket class, but i could not find information about the format you should use to set the proxy for it.

Thanks in advance.
Coordinator
Jun 25, 2013 at 4:10 PM
Check out the SuperSocket.ClientEngine, there is a project called Proxy which can be used in WebSocket4Net:
https://clientengine.codeplex.com/
Jun 25, 2013 at 5:27 PM
Edited Jun 28, 2013 at 1:13 PM
Thanks,
Is the proxy support implemented natively within websocket4net?

The situation I'm in is a bit odd, I'm doing testing on an application that uses Websockets4Net to open a secure web socket with a server which runs on IIS8.
I need to inspect that traffic, but Windows 7 does not natively route WSS/WS traffic trough the OS level proxy which is configured in the INET settings.

What i was planning to do is to patch the current assembly i have with a line that will force the client to route all traffic trough a local proxy i run(either fiddler, or ZAP).

The current code i got is:

public void OpenWebSocket()
{
    this._websocket = new WebSocket(this._config.WS_Server, this._config.WS_SubProtocol, null, customHeaderItems, "", "", WebSocketVersion.None);
    this._websocket.Opened += new EventHandler(this.websocket_Opened);
    this._websocket.Error += new EventHandler<ErrorEventArgs>(this.websocket_Error);
    this._websocket.Closed += new EventHandler(this.websocket_Closed);
    this._websocket.MessageReceived += new EventHandler<MessageReceivedEventArgs>(this.websocket_MessageReceived);
    this._websocket.DataReceived += new EventHandler<DataReceivedEventArgs>(this.websocket_DataReceived);
    this._websocket.EnableAutoSendPing = false;
    this._websocket.Open();
}
}

So I might rephrase the question, is the set proxy method just requires me to set a proxy by giving it the ip:port endpoint, or do i need to implement the entire proxy(HTTP/SOCKS) protocol my self like the examples from the SSCE client show?
Coordinator
Jun 26, 2013 at 2:35 AM
Did you download SuperSocket.ClientEngine??

https://clientengine.codeplex.com/SourceControl/latest#Proxy/Socks5Connector.cs

You can use it directly. The assembly also exists in the the reference folder of WebSocket4Net.
Nov 17, 2013 at 3:42 PM
A have the same problem with proxy. Unfortunately, examples from SuperSocket.ClientEngine don't support http proxy with authorization.
I was able to modify them and add Proxy-Authorization header there. It works for basic authorization.
But I can't get it working for NTLM proxy (and we have some clients who use NTLM proxy).
It seems that I need to make NTLM token as described in this example:
http://msdn.microsoft.com/en-us/library/dd925287(v=office.12).aspx
But I can't find a way to do this. I can try to manually compose it byte by byte, but this seems too hard (and I don't have ntlm enabled proxy to test it).
I can easily create System.Net.WebProxy class and add NetworkCredentials there, but I can apply it only to HttpWebRequest or WebClient and I didn't find a way to extract raw http request data from them (to copy it to the socked buffer).
Maybe you have any ideas?
Coordinator
Nov 17, 2013 at 4:05 PM
It's a good point, it requires a NTLM proxy in the SuperSocket.ClientEngine
Nov 19, 2013 at 7:05 AM
Maybe you have some ideas how to implement it other than manually compose ntlm messages?
Sep 17, 2016 at 4:28 PM
Hello kerryjiang,

I would like to know if the WebSocket4Net / SuperSocket.ClientEngine supports already a NTLM proxy?
Could you please confirm that for me?

Thanks,
Cleiton