Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

客户端关闭,触发OnClosed函数,传入的gnet.Conn很多参数是nil,如localAddr等 #239

Closed
guoguoxiaozhu opened this issue Aug 24, 2021 · 11 comments
Assignees
Labels
help wanted Extra attention is needed question Further information is requested waiting for response waiting for the response from commenter

Comments

@guoguoxiaozhu
Copy link

大神以及各位同仁,你们好
我在测试一个pushServer的sample,在调试的时候,发现在偶发的出现客户端断开的时候,触发的OnClosed函数, 参数gnet.Conn的成员变量很多是nil,不知道这个是不是正常的,因为我刚刚接触gnet框架,不是很熟悉,所以确认一下。
图片
图片

@guoguoxiaozhu guoguoxiaozhu added help wanted Extra attention is needed question Further information is requested labels Aug 24, 2021
@xscode-auto-reply
Copy link

Thanks for opening a new issue. The team has been notified and will review it as soon as possible.
For urgent issues and priority support, visit https://xscode.com/panjf2000/gnet

@mikeqoo1
Copy link

net.conn = nil 如果是斷線後蠻合理, 如果是runtime就蠻奇怪的, 又是偶發現象 感覺跟gnet本身無關

以上是小弟的小小淺見

@guoguoxiaozhu
Copy link
Author

我发现可能是调试的时候,客户端断开,导致这个连接的conn被设置为nil,但这种情况在server端不是经常会出现的吗?这种情况是需要我们来控制,还是类库本身控制?
图片

@panjf2000
Copy link
Owner

你用的是 gnet 的 example 吗?

@panjf2000
Copy link
Owner

在 Windows 下?

@guoguoxiaozhu
Copy link
Author

1、是参考pushserver的例子,尝试做一个数据推送服务
2、是在windows下
3、gnet版本已经是v1.5.3

@guoguoxiaozhu
Copy link
Author

还有一个问题,问什么decode需要通过context来传递参数?在多核环境下,有没有可能出现参数的偏差?两个协程,一个修改了参数,另外一个刚好decode。这个仅仅是感觉,我对go还是不是非常熟悉,在c++的多线程情况下,感觉是有概率出现这种情况的。

@panjf2000
Copy link
Owner

Decode() 什么时候用 context 了?

@panjf2000 panjf2000 added the waiting for response waiting for the response from commenter label Aug 26, 2021
@guoguoxiaozhu
Copy link
Author

guoguoxiaozhu commented Aug 26, 2021

是我写错了,是Encode
在sample中的custom_codec\server\server.go中。
不好意思

图片

@panjf2000
Copy link
Owner

#235 应该修复了这个问题,可以拉一下 master 的最新代码再试试。

@panjf2000
Copy link
Owner

是我写错了,是Encode
在sample中的custom_codec\server\server.go中。
不好意思

图片

c.Context()c.SetContext() 必须在 React() 所在的 goroutine (也就是 event-loop)调用,也就是在 React() 这个事件回调函数里调用,不能在这个函数里再起 goroutine 去调用,这样就能保证不会有 contention 问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested waiting for response waiting for the response from commenter
Projects
None yet
Development

No branches or pull requests

3 participants