go-socket.io
go-socket.io copied to clipboard
bug: memory leak happening.
when i connect 170000+ clients using go-socket.io. the memory use keep growing even I just connect and do nothing.
To Reproduce Brief code to reproduce the behavior.
Expected behavior A clear and concise description of what you expected to happen. memory leak. memory keep growing until oom. Environment (please complete the following information):
- Go version: [e.g. v1.16]
- Server version [e.g. go-socket.io v1.4.5]
Additional context
server.OnEvent("/notification", "toServer", func(s socketio.Conn, msg interface{}) {
noti := msg.(map[string]interface{})
On Linux 3.10 centos7.
here is the heap.out
4729.28MB 28.89% 28.89% 4729.28MB 28.89% bufio.NewWriterSize
2924.13MB 17.86% 46.75% 2924.13MB 17.86% bufio.NewReaderSize
1416.50MB 8.65% 55.40% 1416.50MB 8.65% bytes.makeSlice
884.06MB 5.40% 60.80% 884.06MB 5.40% io.copyBuffer
861.35MB 5.26% 66.07% 912.86MB 5.58% net/textproto.(*Reader).ReadMIMEHeader
575.21MB 3.51% 69.58% 575.21MB 3.51% runtime.malg
568.47MB 3.47% 73.05% 568.47MB 3.47% crypto/tls.Server
389.62MB 2.38% 75.43% 389.62MB 2.38% crypto/aes.(*aesCipherGCM).NewGCM
275.08MB 1.68% 77.11% 298.08MB 1.82% github.com/gorilla/websocket.newConn
246.04MB 1.50% 78.62% 275.54MB 1.68% github.com/googollee/go-socket.io/engineio/transport/websocket.newConn
here is the memestat:
runtime.MemStats
# Alloc = 18400272336
# TotalAlloc = 169292392264
# Sys = 26073060600
# Lookups = 0
# Mallocs = 454336696
# Frees = 399619454
# HeapAlloc = 18400272336
# HeapSys = 18543607808
# HeapIdle = 63258624
# HeapInuse = 18480349184
# HeapReleased = 63258624
# HeapObjects = 54717242
# Stack = 6284509184 / 6284509184
# MSpan = 236746760 / 237682688
# MCache = 9600 / 16384
# BuckHashSys = 1938927
# GCSys = 880963976
# OtherSys = 124341633
# NextGC = 20642027808
# LastGC = 1620124870612394983
# NumForcedGC = 0
# GCCPUFraction = 0.08189029859571963
# DebugGC = false
# MaxRSS = 26046468096
I use gin and https
web.Routes(router, server)
router.RunTLS(":443", "./certification/*.infinitynewtab.com.pem", "./certification/*.infinitynewtab.com.key")
the CLOSE_WAIT is too much and keep growing
213105 CLOSE_WAIT 17 CLOSING 181753 ESTABLISHED 24 FIN_WAIT1 2 FIN_WAIT2 222 LAST_ACK 7 LISTEN 256 SYN_RECV 1 SYN_SENT 49 TIME_WAIT
Hey, @piksonGit It does not actually?
Hey, @piksonGit It does not actually?
yes, it's happening. my server have 64G memory. it ran out.
I will try to fix this issue. Thanks you feedback
I will try to fix this issue. Thanks you feedback
should I use s.Close() in OnDisconnect or OnError method?
I will try to fix this issue. Thanks you feedback
Is it fixed? I also encountered this problem!
Hey, Jerry! Sorry, for slow answer, it is in progress
To https://github.com/googollee/go-socket.io/issues/442#issuecomment-835250470, please call Close()
in OnError()
when you don't want to continue the session. It's also safe to call Close()
in OnDisconnect()
.
To #442 (comment), please call
Close()
inOnError()
when you don't want to continue the session. It's also safe to callClose()
inOnDisconnect()
.
I will have a try
To #442 (comment), please call
Close()
inOnError()
when you don't want to continue the session. It's also safe to callClose()
inOnDisconnect()
.I will have a try
Do you fix the problems?
To #442 (comment), please call
Close()
inOnError()
when you don't want to continue the session. It's also safe to callClose()
inOnDisconnect()
.I will have a try
Do you fix the problems?
No,not solved
I also encountered this problem! Hope for fixed it
hi guys, anyone solved this issue? anyway my swarm node stuck at 98% RAM Usage without any user on it anymore, am i facing the same problem or what?
Easy to duplicate the issue. Suggestion from https://github.com/googollee/go-socket.io/issues/442#issuecomment-846219126 can't work.
Is this problem fixed now?
Has the problem been solved? I have this problem, too? Showing top 10 nodes out of 58 flat flat% sum% cum cum% 32.63MB 30.49% 30.49% 32.63MB 30.49% bufio.NewWriterSize 28.10MB 26.26% 56.75% 28.10MB 26.26% bufio.NewReaderSize 9MB 8.41% 65.16% 9MB 8.41% runtime.malg 7MB 6.54% 71.70% 7MB 6.54% net/textproto.(*Reader).ReadMIMEHeader 5.50MB 5.14% 76.84% 5.50MB 5.14% github.com/gorilla/websocket.newConn 5MB 4.67% 81.52% 5MB 4.67% github.com/googollee/go-socket.io/engineio/transport/websocket.newConn 4MB 3.74% 85.26% 6.50MB 6.07% github.com/googollee/go-socket%2eio.newConn 3MB 2.80% 88.06% 3MB 2.80% net.newFD 2MB 1.87% 89.93% 2MB 1.87% syscall.anyToSockaddr 1.50MB 1.40% 91.33% 1.50MB 1.40% github.com/googollee/go-socket%2eio.(*namespaces).Set
I tried call Close() in OnDisconnect(), but the sessions count still increase. Is there any solution for this problem?
hello bro, is this problem fixed now?
nope, there is a PR that commit by @sshaplygin , I have tried it. This problem still exists.
any updates ?
no update
Abanoub Istfanous @.***> 于2022年5月5日周四 01:06写道:
any updates ?
— Reply to this email directly, view it on GitHub https://github.com/googollee/go-socket.io/issues/442#issuecomment-1117594594, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACJZDZVHNXVPVX2743UKRGTVIKVAHANCNFSM43ZSN7KQ . You are receiving this because you were mentioned.Message ID: @.***>
Hey, @piksonGit ! I merged fix for this problem. Please check up updates on this version
Do you have any time to check leak in your project?
Hey, @piksonGit ! I merged fix for this problem. Please check up updates on this version
Do you have any time to check leak in your project?
hey.glad to hear that.I'll do test on my project. then I'll reply. thank you!
the problem is the same with before. more and more CLOSE_WAIT then the program was killed.
Hey, @piksonGit ! I merged fix for this problem. Please check up updates on this version
Do you have any time to check leak in your project?
my server go version is go1.15.5. Should I upgrade my go version?
my server go version is go1.15.5. Should I upgrade my go version?
if you can testing new version on part of your clients, you will upgrade to new version
Any Updates?
It seems to me that the problem is that after disconnecting the client from the server, the number of connections does not decrease.
With each new connection, an engineio.Server.session session is created in engineio.Server, and after the client is disconnected, the session does not go anywhere.
if use recommendations from https://github.com/googollee/go-socket.io/issues/442#issuecomment-846219126 then we get problem described here https://github.com/googollee/go-socket.io/issues/442#issuecomment-945146037 So many goroutines are being created.
Is it fixed? I also encountered this problem!on v1.6.2
Is it fixed? I also encountered this problem!on v1.6.1