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

kafka.errors.NoBrokersAvailable: NoBrokersAvailable in manged MSK in china region #25

Closed
Xu-Hardy opened this issue Dec 22, 2023 · 2 comments

Comments

@Xu-Hardy
Copy link

Xu-Hardy commented Dec 22, 2023

  • aws-msk-iam-sasl-signer-python version: 1.0.0
  • Python version: py3.11
  • Operating System: win11 22000.2538
  • Method of installation: pip
  • Kafka library name: [e.g. kafka-python] kafka-python
  • Kafka library version 2.0.2
  • Provide us a sample code snippet of your producer/consumer

from kafka import KafkaProducer
from kafka.errors import KafkaError
import socket
import time
from aws_msk_iam_sasl_signer import MSKAuthTokenProvider

class MSKTokenProvider():
def token(self):
token, _ = MSKAuthTokenProvider.generate_auth_token("cn-north-1", aws_debug_creds=True)
print("token", token)
return token

tp = MSKTokenProvider()

producer = KafkaProducer(
bootstrap_servers='b-2..zwc7ax.c4.kafka.cn-north-1.amazonaws.com.cn:9098,'
security_protocol='SASL_SSL',
sasl_mechanism='OAUTHBEARER',
sasl_oauth_token_provider=tp,
client_id=socket.gethostname(),
)

topic = "MSKTutorialTopic"
while True:
try:
inp = input(">")
producer.send(topic, inp.encode())
producer.flush()
print("Produced!")
except Exception as e:
print("Failed to send message:", e)

producer.close()

Description

I try to connect MSK in cn-north-1, I don't know why they throw an error like this.even didn't print debug info

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

Traceback (most recent call last):
File "C:\Users\ec3\Desktop\新建文件夹\potplayer_translate_plug_in\ddd.py", line 17, in
producer = KafkaProducer(
^^^^^^^^^^^^^^
File "C:\Users\ec3\miniconda\Lib\site-packages\kafka\producer\kafka.py", line 381, in init
client = KafkaClient(metrics=self._metrics, metric_group_prefix='producer',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ec3\miniconda\Lib\site-packages\kafka\client_async.py", line 244, in init
self.config['api_version'] = self.check_version(timeout=check_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ec3\miniconda\Lib\site-packages\kafka\client_async.py", line 927, in check_version
raise Errors.NoBrokersAvailable()
kafka.errors.NoBrokersAvailable: NoBrokersAvailable

@Xu-Hardy Xu-Hardy changed the title kafka.errors.NoBrokersAvailable: NoBrokersAvailable kafka.errors.NoBrokersAvailable: NoBrokersAvailable in manged MSK in china region Dec 22, 2023
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@Xu-Hardy
Copy link
Author

not avalible in china region

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

1 participant