watsy0007 opened a new issue #432: get user info by accesskey from ALIYUN 
failed.
URL: https://github.com/apache/rocketmq-client-go/issues/432
 
 
   版本 `v2.0.0-rc1`
   
   accessKey 与 secretKey 权限为发布订阅所有权限.
   调用 `SendSync`得到如下错误
   ```
   send sync message error 
com.aliyun.openservices.ons.api.impl.authority.exception.AuthenticationException:
 get user info by accesskey from ALIYUN failed., 
com.alibaba.ons.open.auth.service.DauthServiceImpl.signatureValidate(DauthServiceImpl.java:258)
   ```
   
   具体代码
   
   `main.go`
   
   ```golang
   rocket := &rmq.MQ{}
        rocket.Start()
   
        for i := 0; i < 10; i++ {
                rocket.SendSyncData([]byte(fmt.Sprintf("hello message %d", i)))
        }
   ```
   
   `mq`
   ```golang
   
   
   type MQ struct {
        p rocketmq.Producer
   }
   
   func (m *MQ) Start() {
        p, err := rocketmq.NewProducer(
                producer.WithNameServer([]string{config.MQHost}),
                producer.WithCredentials(primitive.Credentials{
                        AccessKey:     config.MQAccessKey,
                        SecretKey:     config.MQSecretKey,
                        SecurityToken: config.MQChannel,
                }),
                producer.WithNamespace(config.MQNameSpace),
                producer.WithRetry(3),
        )
   
        logger.Debug("configs: [%s], [%s], [%s]", config.MQHost, 
config.MQAccessKey, config.MQSecretKey)
        if err != nil {
                log.Panicf("can't connect to producer: %v", err)
        }
   
        err = p.Start()
        if err != nil {
                log.Panicf("start rmq error %v", err)
        }
   
        logger.Debug("connect to mq success :%v", p)
        m.p = p
   }
   
   
   func (m *MQ) SendSyncData(data []byte) {
        msg := primitive.NewMessage(config.MQTopic, data)
        r , err := m.p.SendSync(context.Background(), msg)
        if err != nil {
                logger.Warn("send sync message error %v", err)
                return
        }
        logger.Debug("send message success :%v", r.String())
   }
   
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to