Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

不使用证书的情况下调用ssl的url,服务无法连接

Đang mở
#382 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, node.js
Lĩnh vực
distributed-systems

Hướng nghiên cứu

Bắt đầu với constructor của Node client và các tùy chọn tlsAllowInsecureConnection và tlsValidateHostname, sau đó tái hiện ví dụ subscription được cung cấp với service URL pulsar+ssl và bật logging của client. So sánh lỗi kết nối và lỗi partition metadata với hành vi của Java; được xem là hoàn tất khi Node client có thể kết nối và tạo consumer mà không gặp ConnectError khi tắt xác thực chứng chỉ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

以下是node代码,在java中是可以通过```
PulsarClient client = PulsarClient.builder().serviceUrl(brokerServerUrl).allowTlsInsecureConnection(true)
.authentication(new IoTAuthentication(iotAccessId, iotSecretKey)).build();
Consumer consumer = client.newConsumer(Schema.STRING).topic(String.format("%s/iot/event", iotAccessId))
.subscriptionName(subscriptionName).subscriptionType(SubscriptionType.Failover)
.autoUpdatePartitions(Boolean.FALSE).subscribe();

这种方式来跳过ssl证书的,在下面node中我也加入了tlsAllowInsecureConnection: true,
            tlsValidateHostname: false,这两个参数但是无法连接到服务



`const Pulsar = require('pulsar-client');
const crypto = require('crypto');
const iotAccessId = "yGmZyJnpqPPIGwzj1564";
const iotSecretKey="b9fab8817fa64f4ab6424d6a7035d2e7";
const brokerSSLServerUrl = "pulsar+ssl://iot-north-mq.heclouds.com:6651/";
const iotSubscriptionName="yGmZyJnpqPPIGwzj1564-sub";

const token = JSON.stringify({
    tenant: iotAccessId,
    password: sha256(iotAccessId + sha256(iotSecretKey)).substring(4, 20)
});

(async () => {
    try {
        console.log("token:", token);
        // Create a client
        let authenticationToken = new Pulsar.AuthenticationToken({
            token: token
        });

        Pulsar.Client.setLogHandler((level, file, line, message) => {
            console.log('[%s][%s:%d] %s', Pulsar.LogLevel.toString(level), file, line, message);
        });

        const client = new Pulsar.Client({
            serviceUrl: brokerSSLServerUrl,
            authentication: authenticationToken,
            tlsAllowInsecureConnection: true,
            tlsValidateHostname: false,
        });


        console.log("client:", client);

        // Create a consumer
        const consumer = await client.subscribe({
            topic: `${iotAccessId}/iot/event`,
            // topic: 'persistent://yGmZyJnpqPPIGwzj1564/iot/event-partition-0',
            subscription: iotSubscriptionName,
            subscriptionType: 'Failover'
        });

        console.log("consumer:", consumer);

        // Receive the message
        const msg = await consumer.receive();
        console.log(msg.getData().toString());
        consumer.acknowledge(msg);

        await consumer.close();
        await client.close();
    } catch (error) {
        console.error("An error occurred:", error.message);
        console.error(error.stack);
    }
})();

function sha256(data) {
    return crypto.createHash('sha256').update(data, 'utf8').digest('hex');
}`


最下面是报错信息```
[INFO][Client:86] Subscribing on Topic :yGmZyJnpqPPIGwzj1564/iot/event
[INFO][ClientConnection:187] [<none> -> pulsar+ssl://iot-north-mq.heclouds.com:6651] Create ClientConnection, timeout=10000
[INFO][ConnectionPool:124] Created connection for pulsar+ssl://iot-north-mq.heclouds.com:6651-pulsar+ssl://iot-north-mq.heclouds.com:6651-0
[INFO][ClientConnection:403] [10.10.80.213:63773 -> 218.201.45.7:6651] Connected to broker
[ERROR][ClientConnection:1318] [10.10.80.213:63773 -> 218.201.45.7:6651] Connection closed with ConnectError (refCnt: 2)
[INFO][ConnectionPool:141] Remove connection for pulsar+ssl://iot-north-mq.heclouds.com:6651-pulsar+ssl://iot-north-mq.heclouds.com:6651-0
[ERROR][ClientImpl:507] Error Checking/Getting Partition Metadata while Subscribing on persistent://yGmZyJnpqPPIGwzj1564/iot/event -- ConnectError
[INFO][ClientConnection:275] [10.10.80.213:63773 -> 218.201.45.7:6651] Destroyed connection to pulsar+ssl://iot-north-mq.heclouds.com:6651-0
An error occurred: Failed to create consumer: ConnectError
Error: Failed to create consumer: ConnectError
Ngôn ngữ chính
C++
Star
164
Fork
99
Merge trung bình
5 ngày 18 giờ
Pull request đã merge (30 ngày)
2

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/pulsar-client-node

Tất cả issue của apache/pulsar-client-node

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.