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

发送时间同步没有收到服务器返回 #598

Closed
taofu328 opened this issue Dec 25, 2024 · 10 comments
Closed

发送时间同步没有收到服务器返回 #598

taofu328 opened this issue Dec 25, 2024 · 10 comments

Comments

@taofu328
Copy link

使用mqttx客户端测试,
productId:1838407478897602560
deviceId:109C553500C0C00007B19514
上行topic:/1838407478897602560/109C553500C0C00007B19514/time-sync
订阅topic:/1838407478897602560/109C553500C0C00007B19514/time-sync/reply
发送消息内容:{"messageId":"4"},没有收到服务器返回消息,是怎么回事呢

@zhou-hao
Copy link
Member

是使用的官方协议吗?

@taofu328
Copy link
Author

是使用的官方协议吗?

使用的官方协议,通过emqx接入的。

@taofu328
Copy link
Author

测试了一下,使用jetlinks自带的mqtt服务能获取时间戳,通过emqx接入就不行

@zhou-hao
Copy link
Member

你订阅了这个topic没

@taofu328
Copy link
Author

订阅了的,截图里是通过通配符订阅的,通过emqx接入的,收到的是上行消息,通过jetlinks自带mqtt服务器接入的,没有收到上行消息,收到了时间戳。测试过订阅/1838407478897602560/109C553500C0C00007B19514/time-sync/reply,通emqx接入的也收不到时间戳,通过jetlinks接入的能收到
emqx
jetlinks

@zhou-hao
Copy link
Member

官方协议好像 时间同步的topic 没有加到路由里。所以不会去订阅emqx。 你修改一下官方协议试试。 https://github.com/jetlinks/jetlinks-official-protocol/blob/v3/src/main/java/org/jetlinks/protocol/official/JetLinksProtocolSupportProvider.java#L47

@taofu328
Copy link
Author

好的,我研究一下,谢谢

@taofu328
Copy link
Author

taofu328 commented Jan 2, 2025

我按照文档[MQTT协议解析 | JetLinks 物联网基础平台],把时间同步的topic加到路由里,但是不起作用。应该怎么修改呢

CompositeProtocolSupport support = new CompositeProtocolSupport();
        support.setId("jetlinks.v3.0");
        support.setName("JetLinks V3.0");
        support.setDescription("JetLinks Protocol Version 3.0");

        support.addRoutes(DefaultTransport.MQTT, Arrays.asList(
                Route.mqtt("/*/time-sync")
                        .group("时间同步")
                        .upstream(true)
                        .downstream(false)
                        .description("获取服务器时间戳")
                        .example("{\"messageId\":\"消息ID\"}")
                        .build()
        ));

        support.addRoutes(DefaultTransport.MQTT, Arrays
                .stream(TopicMessageCodec.values())
                .map(TopicMessageCodec::getRoute)
                .filter(Objects::nonNull)
                .collect(Collectors.toList())
        );

@zhou-hao
Copy link
Member

zhou-hao commented Jan 2, 2025

不要调用两次。 同一个addRoutes中添加。
应该是这样吧 /*/*/time-sync

@taofu328
Copy link
Author

taofu328 commented Jan 2, 2025

可以了,谢谢。我看到TopicMessageCodec里面是topic都是一个星号,这里也就只写了一个星号。

@taofu328 taofu328 closed this as completed Jan 2, 2025
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