nsqio / go-nsq

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

REGISTER command fails #190

Closed isadon closed 8 years ago

isadon commented 8 years ago

I set up the following setupNSQ function to connect to nsq and register a queue topic and channel:

import (
q "github.com/bitly/go-nsq"
)

func setupNSQ() (*q.Producer, error) {
qConn := q.NewConn(":4150", q.NewConfig(), NSQConnDelegate{})
_, err := qConn.Connect()
if err != nil {
    return nil, err
}
defer qConn.Close()

err = qConn.WriteCommand(q.Register(NsqSnsChatTopic, NsqSnsChatTopicChSend))
if err != nil {
    return nil, err
}
return q.NewProducer(":4161", q.NewConfig())

After calling the function I get the following error on the nsqd instance:

[nsqd] 2016/08/26 00:02:41.223414 TCP: new client(127.0.0.1:50013)
[nsqd] 2016/08/26 00:02:41.223432 CLIENT(127.0.0.1:50013): desired protocol magic '  V2'
[nsqd] 2016/08/26 00:02:41.223613 [127.0.0.1:50013] IDENTIFY: {ShortID:adonis-mbp LongID:adonis-mbp ClientID:adonis-mbp Hostname:adonis-mbp HeartbeatInterval:30000 OutputBufferSize:16384 OutputBufferTimeout:250 FeatureNegotiation:true TLSv1:false Deflate:false DeflateLevel:6 Snappy:false SampleRate:0 UserAgent:go-nsq/1.0.6 MsgTimeout:0}
[nsqd] 2016/08/26 00:02:41.223796 ERROR: [127.0.0.1:50013] - E_INVALID invalid command REGISTER
[nsqd] 2016/08/26 00:02:41.223819 PROTOCOL(V2): [127.0.0.1:50013] exiting ioloop
[nsqd] 2016/08/26 00:02:41.223842 ERROR: client(127.0.0.1:50013) - E_INVALID invalid command REGISTER
[nsqd] 2016/08/26 00:02:41.223868 PROTOCOL(V2): [127.0.0.1:50013] exiting messagePump

This seems to be an issue with the go-nsq Command Register Function.

ploxiln commented 8 years ago

No need for the producer to register the topic (or any channel), it can just publish to the topic, and the topic will be created automatically.

isadon commented 8 years ago

Hi @ploxiln I know the producer doesn't need to create it but I filed a separate issue because the REGISTER command is failing as seen above. In my case I don't want to have to submit a post request or browse to the nsqadmin website to pre-create topics. So I'm attempting to create them via REGISTER above.

mreiferson commented 8 years ago

The REGISTER command is part of nsqlookupd's protocol, not nsqd and shouldn't ever need to triggered manually.

isadon commented 8 years ago

Same as the other issue I filed :) would be nice to have some documentation detailing this info above the appropriate function call or should not be exported. Thanks.