nsqio / go-nsq

The official Go package for NSQ
MIT License
2.59k stars 444 forks source link

"IO error - EOF" error after calling producer.Stop() #212

Closed tmpapageorgiou closed 7 years ago

tmpapageorgiou commented 7 years ago

The error message are generate intermitantly lways after call producer.Stop()

(localhost:4150) IO error - EOF

The following code reproduces the problem:

package main                                                                                                                        

import (                                                                                                                            
    "bitbucket.org/tpapageorgiou/mytest/broker"                                                                   
    log "github.com/Sirupsen/logrus"                                                                                                
    "github.com/nsqio/go-nsq"                                                                                                       
)                                                                                                                                   

func main() {                                                                                                                       
    config := nsq.NewConfig()                                                                                                       

    buffer := []byte{`{"test": "123"}`}                                                                                                            

    for i := 0; i < 100; i++ {                                                                                                      
        producer, _ := nsq.NewProducer("localhost:4150", config)                                                                    
        producer.SetLogger(broker.NewNSQLogrusLoggerAtLevel(log.DebugLevel))                                                        
        err := producer.Publish("test_topic", buffer)                                                                               

        if err != nil {                                                                                                             
            log.Error(err)                                                                                                          
        }                                                                                                                           
        producer.Stop()                                                                                                             
    }                                                                                                                               
}   

I am using:

tmpapageorgiou commented 7 years ago

Thi is a diplicated of https://github.com/nsqio/go-nsq/issues/184

ploxiln commented 7 years ago

This is indeed a duplicate, but it was thought to have been fixed in #201 which was included in go-nsq v1.0.6