You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/06/28 03:21:52 UTC

[GitHub] [pulsar] wolfstudy opened a new issue #11123: When using TopicsPattern mode to subscribe, there will be a 403 error

wolfstudy opened a new issue #11123:
URL: https://github.com/apache/pulsar/issues/11123


   **Describe the bug**
   
   ```
   Code: 403, Reason: {"reason":"Unauthorized to validateNamespaceOperation for operation [GET_TOPICS] on namespace [pulsar-8j7gam3dx58n/default]"}
   ```
   
   
   **Screenshots**
   
   ![企业微信截图_1da1205e-82c5-4608-b6c8-ff4f50d1d571](https://user-images.githubusercontent.com/20965307/123574650-d4673580-d802-11eb-8a00-17cc23e626d7.png)
   
   
   **Desktop (please complete the following information):**
    - OS: Mac OS
    - Go version: master
   
   
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] wolfstudy commented on issue #11123: When using TopicsPattern mode to subscribe, there will be a 403 error

Posted by GitBox <gi...@apache.org>.
wolfstudy commented on issue #11123:
URL: https://github.com/apache/pulsar/issues/11123#issuecomment-869323055


   ```
   package main
   
   import (
   	"context"
   	"fmt"
   	"log"
   	"time"
   
   	"github.com/apache/pulsar-client-go/pulsar"
   )
   
   func main() {
   
   	client, err := pulsar.NewClient(pulsar.ClientOptions{
   		URL:               "http://localhost:8080",                                                                                                                       
   		Authentication:    pulsar.NewAuthenticationToken("eyJrZxxxxxx"), 
   		OperationTimeout:  30 * time.Second,
   		ConnectionTimeout: 30 * time.Second,
   	})
   	if err != nil {
   		log.Fatalf("Could not instantiate Pulsar client: %v", err)
   	}
   
   	defer client.Close()
   
   	consumer, err := client.Subscribe(pulsar.ConsumerOptions{
   		//Topic: "pulsar-xxxxx/default/muzhao-test-queue", 
   		//Topics: []string{"pulsar-xxxxx/default/micro-email-send"},
   		TopicsPattern: "pulsar-xxxxx/default/.*",
   		SubscriptionName: "muzhao-test-queue",
   		Type:             pulsar.Shared,
   	})
   	if err != nil {
   		log.Fatal(err)
   	}
   	defer consumer.Close()
   
   	for i := 0; i < 10; i++ {
   		msg, err := consumer.Receive(context.Background())
   		if err != nil {
   			log.Fatal(err)
   		}
   
   		fmt.Printf("Received message--------------- msgId: %#v -- content: '%s'\n",
   			msg.ID(), string(msg.Payload()))
   
   		consumer.Ack(msg)
   	}
   
   	if err := consumer.Unsubscribe(); err != nil {
   		log.Fatal(err)
   	}
   
   }
   ```


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] wolfstudy closed issue #11123: When using TopicsPattern mode to subscribe, there will be a 403 error

Posted by GitBox <gi...@apache.org>.
wolfstudy closed issue #11123:
URL: https://github.com/apache/pulsar/issues/11123


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] wolfstudy edited a comment on issue #11123: When using TopicsPattern mode to subscribe, there will be a 403 error

Posted by GitBox <gi...@apache.org>.
wolfstudy edited a comment on issue #11123:
URL: https://github.com/apache/pulsar/issues/11123#issuecomment-869323055


   It is normal to use Topic and Topics, and the demo of TopicsPattern as follows:
   
   ```
   package main
   
   import (
   	"context"
   	"fmt"
   	"log"
   	"time"
   
   	"github.com/apache/pulsar-client-go/pulsar"
   )
   
   func main() {
   
   	client, err := pulsar.NewClient(pulsar.ClientOptions{
   		URL:               "http://localhost:8080",                                                                                                                       
   		Authentication:    pulsar.NewAuthenticationToken("eyJrZxxxxxx"), 
   		OperationTimeout:  30 * time.Second,
   		ConnectionTimeout: 30 * time.Second,
   	})
   	if err != nil {
   		log.Fatalf("Could not instantiate Pulsar client: %v", err)
   	}
   
   	defer client.Close()
   
   	consumer, err := client.Subscribe(pulsar.ConsumerOptions{
   		//Topic: "pulsar-xxxxx/default/muzhao-test-queue", 
   		//Topics: []string{"pulsar-xxxxx/default/micro-email-send"},
   		TopicsPattern: "pulsar-xxxxx/default/.*",
   		SubscriptionName: "muzhao-test-queue",
   		Type:             pulsar.Shared,
   	})
   	if err != nil {
   		log.Fatal(err)
   	}
   	defer consumer.Close()
   
   	for i := 0; i < 10; i++ {
   		msg, err := consumer.Receive(context.Background())
   		if err != nil {
   			log.Fatal(err)
   		}
   
   		fmt.Printf("Received message--------------- msgId: %#v -- content: '%s'\n",
   			msg.ID(), string(msg.Payload()))
   
   		consumer.Ack(msg)
   	}
   
   	if err := consumer.Unsubscribe(); err != nil {
   		log.Fatal(err)
   	}
   
   }
   ```


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org