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

WS: use of closed network connection #3

Closed
MarcMagnin opened this issue Jan 16, 2018 · 1 comment
Closed

WS: use of closed network connection #3

MarcMagnin opened this issue Jan 16, 2018 · 1 comment

Comments

@MarcMagnin
Copy link
Contributor

Hi,

I'd like to use the WS connection but I got the following errors when connecting up (broker output):

Time:2018-01-16 17:48:12        file:client.go  level:ERROR     read packet error: read tcp 127.0.0.1:1888->127.0.0.1:35916: use of closed network connection clientID = f27c46e3-8d81-4b62-b405-e9b5b2149f9f
Time:2018-01-16 17:48:12        file:client.go  level:DEBUG     Recv message: DISCONNECT: dup: false qos: 0 retain: false rLength: 0 clientID = f27c46e3-8d81-4b62-b405-e9b5b2149f9f
Time:2018-01-16 17:48:12        file:broker.go  level:WARN      client exist, close old... clientID = f27c46e3-8d81-4b62-b405-e9b5b2149f9f
Time:2018-01-16 17:48:12        file:client.go  level:DEBUG     Recv message: DISCONNECT: dup: false qos: 0 retain: false rLength: 0 clientID = f27c46e3-8d81-4b62-b405-e9b5b2149f9f
Time:2018-01-16 17:48:12        file:client.go  level:ERROR     read packet error: read tcp 127.0.0.1:1888->127.0.0.1:35918: use of closed network connection clientID = f27c46e3-8d81-4b62-b405-e9b5b2149f9f
Time:2018-01-16 17:48:12        file:client.go  level:DEBUG     Recv message: DISCONNECT: dup: false qos: 0 retain: false rLength: 0 clientID = f27c46e3-8d81-4b62-b405-e9b5b2149f9f

I'm connecting using the pahoMQTT client like the following:

opts := pahoMQTT.NewClientOptions()
opts.AddBroker("ws://0.0.0.0:1888/ws")
opts.SetClientID("client-test")
opts.SetKeepAlive(time.Duration(120 * time.Second))
opts.SetConnectTimeout(time.Duration(5 * time.Second))

mqttClient := pahoMQTT.NewClient(opts)
token := mqttClient.Connect()
if token.WaitTimeout(time.Duration(5000*time.Millisecond)) || token.Error() != nil {
	log.Panic("Unable to connect to MQTT. ", token.Error())
}

Btw token.Error() == nil

Many thanks.

@chowyu08
Copy link
Contributor

I have fix this, please clone the newest code, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants