[Question] <traffic from local machine to websocket server is high>
zhouziyan opened this issue · 3 comments
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
I am using this repo to work with websocket thing. My case is very simple, just listening some data from a web server.
After I start my program, I use $ sudo nethogs command to see the network traffic.
I saw that SENT is 50k/s and RECEIVED is 500k/s.
I did't sent any traffic to websocket server. I'd like to ask what message is included in SENT and how to disable it?
Could anybody from community can help me?
Expected Behavior
No response
Steps To Reproduce
No response
Anything else?
No response
I use Wireshark to capture tcp/udp traffic of server.go and find no data is received or sent by server except for heartbeat every 15 seconds.
Please share you code for deep investigation.
@Hayden-Chang try to connect to wss://stream.binance.com:9443/ws/btcusdt@bookTicker
I'd like to ask what message is included in SENT and how to disable it?
The websocket connection responds to pings by sending a pong. Otherwise, the connection only sends data written by the application.
It's doubtful that the pong traffic is substantial. Add this code to your application to observe the pong data:
c.SetPingHandler(func(message string) error {
fmt.Printf("writing %d pong bytes\n", len(message))
_ = c.WriteControl(websocket.PongMessage, []byte(message), time.Now().Add(time.Second))
return nil
})
You can disable pongs using the following code. I don't recommend this because the server likely close the connection when the client does not respond to the ping.
c.SetPingHandler(func(message string) error {
return nil
})