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

关于ws_conn读取可能会卡的问题 #32

Closed
brantlane opened this Issue Jun 13, 2018 · 7 comments

Comments

Projects
None yet
3 participants
@brantlane

brantlane commented Jun 13, 2018

测试publish稍微大点的数据(字符串过千)的时候,会出现非常长的超时。调试代码发现wc_conn中的read可能有问题,导致chan等待。当然,注释也写了goroutine不安全。哈哈。

// goroutine not safe
func (wsConn *WSConn) Read(p []byte) (n int, err error) {
err = <-wsConn.buf_lock //等待写入数据
if err != nil {
//读取数据出现异常了
return
}
if wsConn.buffer.Len() == 0 {
//再等一次
err = <-wsConn.buf_lock //等待写入数据
if err != nil {
//读取数据出现异常了
return
}
}
return wsConn.buffer.Read(p)
}

@liangdas

This comment has been minimized.

Show comment
Hide comment
@liangdas

liangdas Jun 16, 2018

Owner

应该是buffer设置的缓冲区比你发的数据小造成的

Owner

liangdas commented Jun 16, 2018

应该是buffer设置的缓冲区比你发的数据小造成的

@brantlane

This comment has been minimized.

Show comment
Hide comment
@brantlane

brantlane Jun 19, 2018

恩,调大缓冲是可以解决问题。但是这个大小的设定有没有什么依据?

brantlane commented Jun 19, 2018

恩,调大缓冲是可以解决问题。但是这个大小的设定有没有什么依据?

@liangdas

This comment has been minimized.

Show comment
Hide comment
@liangdas

liangdas Jun 20, 2018

Owner

根据游戏类型,每次传送数据量大小来定吧,设置得大了占服务端内存多

Owner

liangdas commented Jun 20, 2018

根据游戏类型,每次传送数据量大小来定吧,设置得大了占服务端内存多

@brantlane

This comment has been minimized.

Show comment
Hide comment
@brantlane

brantlane Jun 21, 2018

ok。先这样。

brantlane commented Jun 21, 2018

ok。先这样。

@brantlane brantlane closed this Jun 21, 2018

@Linnkenn

This comment has been minimized.

Show comment
Hide comment
@Linnkenn

Linnkenn Sep 17, 2018

Contributor

确认一下,
1:看代码是否MaxMsgLen 只对ws连接起作用?
2:MqttAgent的读写buffer的大小默认为1024,当数据量大的时候需要将该大小设置更大是吧?
@liangdas

Contributor

Linnkenn commented Sep 17, 2018

确认一下,
1:看代码是否MaxMsgLen 只对ws连接起作用?
2:MqttAgent的读写buffer的大小默认为1024,当数据量大的时候需要将该大小设置更大是吧?
@liangdas

@liangdas

This comment has been minimized.

Show comment
Hide comment
@liangdas

liangdas Sep 17, 2018

Owner

2:MqttAgent的读写buffer的大小默认为1024,当数据量大的时候需要将该大小设置更大是吧?
网络通信数据量比较大,buffer就要设置更大一些

Owner

liangdas commented Sep 17, 2018

2:MqttAgent的读写buffer的大小默认为1024,当数据量大的时候需要将该大小设置更大是吧?
网络通信数据量比较大,buffer就要设置更大一些

@Linnkenn

This comment has been minimized.

Show comment
Hide comment
@Linnkenn

Linnkenn Sep 17, 2018

Contributor

2:MqttAgent的读写buffer的大小默认为1024,当数据量大的时候需要将该大小设置更大是吧?
网络通信数据量比较大,buffer就要设置更大一些

是否将buffer的读写buffer的大小设为配置文件中的MaxMsgLen更好一些?
@liangdas

Contributor

Linnkenn commented Sep 17, 2018

2:MqttAgent的读写buffer的大小默认为1024,当数据量大的时候需要将该大小设置更大是吧?
网络通信数据量比较大,buffer就要设置更大一些

是否将buffer的读写buffer的大小设为配置文件中的MaxMsgLen更好一些?
@liangdas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment