WS -> TCP proxy. I do conn.ReadMessage() in the websocket connection loop and then I send it to the TCP server I connected to earlier, then I take the response from the TCP server and send it back. It seems to be simple.
ws -> tcp
ws <- tcp
But the problem is that I read, then send, then read the response and send back. If a message conditionally weighs 100 MB, then I will read 100 MB first and then send it back.
Can I read those 100 MB from the websockets over TCP frames and send them out immediately or something like that? Or which way should I think?
I think it can copy a lot of unnecessary data, such as HTTP headers ws connection. And won't it work in a similar way, i.e., it first waits for a full message from firstWebSocketConn, and then sends to secondTCPConn?
In raw TCP there are no full messages AFAIK. Unless you add metadata, like HTTP & Websockets
Обсуждают сегодня