rocketmq控制台启动访问后报错connect to <null> failed

错误日志:

java.lang.RuntimeException: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to <null> failed
    at com.google.common.base.Throwables.propagate(Throwables.java:160)
    at org.apache.rocketmq.console.task.DashboardCollectTask.collectTopic(DashboardCollectTask.java:156)
    at org.apache.rocketmq.console.task.DashboardCollectTask$$FastClassBySpringCGLIB$$c818b8cd.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
    at org.apache.rocketmq.console.aspect.admin.MQAdminAspect.aroundMQAdminMethod(MQAdminAspect.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)

目前我用的rocketmq-console的版本是1.0.1

按理说我在application.properties中配置了

rocketmq.config.namesrvAddr=localhost:9876

并且他的默认值就是localhost:9876,不应该报错connect to <null>,网上的大部分解决方案都是网络原因,打开防火墙就可以了,但是我的rocketmq与控制台都部署在同一个电脑上不应该出现防火墙问题,后来我尝试在启动脚本后加上namesrv的配置,问题解决了启动脚本如下:

java -jar rocketmq-console-ng-1.0.1.jar --rocketmq.config.namesrvAddr=localhost:9876

问题完美解决,如果您想用idea直接启动,可以在启动配置中加如下配置:

  • 9
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
#include <stdio.h> #include <string.h> #include <libwebsockets.h> #define BUFFER_SIZE 4096 static struct lws *wsi_client = NULL; static int callback_chat(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len) { switch (reason) { case LWS_CALLBACK_CLIENT_ESTABLISHED: // 连接建立,记录wsi_client wsi_client = wsi; break; case LWS_CALLBACK_CLIENT_RECEIVE: // 接收到服务端发来的消息,输出到控制台 printf("[Client] Message received: %s\n", (char *)in); break; case LWS_CALLBACK_CLIENT_CLOSED: // 连接关闭,设置wsi_client为NULL wsi_client = NULL; break; default: break; } return 0; } static struct lws_protocols protocols[] = { { "chat", callback_chat, 0, BUFFER_SIZE }, { NULL, NULL, 0, 0 } }; int main(int argc, char **argv) { struct lws_context_creation_info info; memset(&info, 0, sizeof(info)); info.port = CONTEXT_PORT_NO_LISTEN; info.protocols = protocols; info.gid = -1; info.uid = -1; struct lws_context *context = lws_create_context(&info); if (context == NULL) { fprintf(stderr, "Error: Failed to create libwebsocket context\n"); return -1; } struct lws_client_connect_info connect_info; memset(&connect_info, 0, sizeof(connect_info)); connect_info.context = context; connect_info.address = "localhost"; connect_info.port = 8080; connect_info.path = "/"; connect_info.host = lws_canonical_hostname(context); connect_info.origin = connect_info.host; connect_info.protocol = protocols[0].name; struct lws *wsi = lws_client_connect_via_info(&connect_info); if (wsi == NULL) { fprintf(stderr, "Error: Failed to connect to server\n"); lws_context_destroy(context); return -1; } while (wsi_client == NULL) { lws_service(context, 50); } char buffer[BUFFER_SIZE]; while (fgets(buffer, BUFFER_SIZE, stdin)) { if (wsi_client == NULL) { break; } buffer[strlen(buffer) - 1] = '\0'; lws_write(wsi_client, (unsigned char *)buffer, strlen(buffer), LWS_WRITE_TEXT); } lws_context_destroy(context); return 0; }这段代码是否有问题?
06-08
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值