Question

I'm writing a simple reverse proxy which will need to handle http GETs and POSTs and WebSocket connections. Numbers of simultaneous clients will be low so I had hoped to use HttpListener. I'm struggling to see how to use that to proxy a WebSocket connection though.

I think responses have to be sent via HttpListenerResponse. For GETs and POSTs this is easy. For WebSockets I'd need to send handshake data then keep the connection open to send further messages from the server being proxyed. The only way I can see to send data using HttpListenerResponse is to call Close(), presumably preventing further use of the underlying socket.

Similar issues presumably exist with trying to use HttpListenerRequest to receive later websocket messages from the client.

Am I missing something here or is there no way to use HttpListener with websockets?

Was it helpful?

Solution

Seems there is no way with HttpListener right now. You have to wait .NET 4.5.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top