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

注册失败 #334

Open
caiwenju opened this issue Sep 22, 2023 · 1 comment
Open

注册失败 #334

caiwenju opened this issue Sep 22, 2023 · 1 comment

Comments

@caiwenju
Copy link

Your question

publisher.isRegistered() 状态一直为false注册失败
describe your question clearly
我在第一台机器部署了服务端,健康测试完全没问题,然后本地连接他一直无法注册成功(publisher.isRegistered()的值为false)发布不了数据

Your scenes

部署了服务端、本地连接服务端无法成功
describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • SOFARegistry version:5.2.0
  • JVM version (e.g. java -version):
    openjdk version "1.8.0_382"
    OpenJDK Runtime Environment Corretto-8.382.05.1 (build 1.8.0_382-b05)
    OpenJDK 64-Bit Server VM Corretto-8.382.05.1 (build 25.382-b05, mixed mode)
  • OS version (e.g. uname -a):
    Darwin MacBook-Pro-5.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 21:01:02 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8112 arm64
  • Maven version:
    Apache Maven 3.9.4 (dfbb324ad4a7c8fb0bf182e6d91b0ae20e3d2dd9)
    Maven home: /opt/homebrew/Cellar/maven/3.9.4/libexec
    Java version: 1.8.0_382, vendor: Amazon.com Inc., runtime: /Users/caiwenjun/Library/Java/JavaVirtualMachines/corretto-1.8.0_382/Contents/Home/jre
    Default locale: zh_CN, platform encoding: UTF-8
    OS name: "mac os x", version: "13.3", arch: "aarch64", family: "mac"
  • IDE version:
    IntelliJ IDEA 2023.2.2 (Ultimate Edition)
    Build #IU-232.9921.47, built on September 13, 2023
    Licensed to Trial User
    Subscription is active until October 18, 2023.
    Runtime version: 17.0.8+7-b1000.22 aarch64
    VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
    macOS 13.3
    GC: G1 Young Generation, G1 Old Generation
    Memory: 4096M
    Cores: 8

Kotlin: 232-1.9.0-IJ9921.47
package org.sofa;
1.0-SNAPSHOT

具体连接代码如下
import com.alipay.sofa.registry.client.api.Publisher;
import com.alipay.sofa.registry.client.api.RegistryClientConfig;
import com.alipay.sofa.registry.client.api.registration.PublisherRegistration;
import com.alipay.sofa.registry.client.provider.DefaultRegistryClient;
import com.alipay.sofa.registry.client.provider.DefaultRegistryClientConfigBuilder;

public class Pub {
public static void main(String[] args) {

    // 构建客户端实例
    RegistryClientConfig config = DefaultRegistryClientConfigBuilder.start().setRegistryEndpoint("192.168.0.15").setRegistryEndpointPort(9603).build();
    DefaultRegistryClient registryClient = new DefaultRegistryClient(config);
    registryClient.init();
    // 构造发布者注册表
    String dataId = "com.alipay.test.demo.service:1.0.0@DEFAULT";
    PublisherRegistration registration = new PublisherRegistration(dataId);
    registration.setGroup("TEST_GROUP");
    registration.setAppName("TEST_APP");
    // 将注册表注册进客户端并发布数据
    try {
        // 将注册表注册进客户端并发布数据
        Publisher publisher = registryClient.register(registration, "223.104.68.55:9090?xx=re");
        publisher.republish("223.104.68.55:9090?xx=zz");
        if (!publisher.isRegistered()) {
            System.err.println("数据注册失败");
            // 处理注册失败的逻辑

// publisher.unregister();
} else {
// 数据注册成功的逻辑
System.out.println("数据注册成功");
}
} catch (Exception e) {
e.printStackTrace();
System.err.println("数据注册失败:" + e.getMessage());
}
}
}

@NickNYU
Copy link
Contributor

NickNYU commented Sep 25, 2023

.setRegistryEndpoint("192.168.0.15") 这个192.168网段我理解从你本地应该是联不通的,除非是本地和SOFA Registry的session都是192.168网段的
你可以先ping一下看看是否网络可通

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

2 participants