.NET库,可以将套接字从HTTP切换到WebSocket协议

时间:2021-04-02 18:12:00

I need to handle HTTP requests and WebSocket connections on single port 80 with my custom Windows service.

我需要使用自定义Windows服务在单个端口80上处理HTTP请求和WebSocket连接。

So, as I understand it: HTTP connection should be switched to WebSocket protocol on demand from client with Upgrade request header.

因此,据我所知:HTTP连接应该根据需要从具有升级请求标头的客户端切换到WebSocket协议。

Question: Is there any server library that can handle HTTP requests on socket and can switch socket to WebSocket on demand?

问题:是否有任何服务器库可以处理套接字上的HTTP请求,并且可以根据需要将套接字切换到WebSocket?

Or may be there are any another solutions for standalone application/service?

或者可能还有其他独立应用程序/服务的解决方案?

1 个解决方案

#1


0  

You could use a TCP proxy port to divide traffic between the two targets. For example, all traffic would come in to port 80, but then HTTP traffic would be routed internally to 8001 and WS traffic to 8002. https://github.com/lifeemotions/websocketproxy

您可以使用TCP代理端口来划分两个目标之间的流量。例如,所有流量都将进入端口80,但是HTTP流量将在内部路由到8001,WS流量将路由到8002. https://github.com/lifeemotions/websocketproxy

#1


0  

You could use a TCP proxy port to divide traffic between the two targets. For example, all traffic would come in to port 80, but then HTTP traffic would be routed internally to 8001 and WS traffic to 8002. https://github.com/lifeemotions/websocketproxy

您可以使用TCP代理端口来划分两个目标之间的流量。例如,所有流量都将进入端口80,但是HTTP流量将在内部路由到8001,WS流量将路由到8002. https://github.com/lifeemotions/websocketproxy