I have cloned hivemq community edition broker from github using following link https://github.com/hivemq/hivemq-community-edition.git and facing issues

i have cloned hivemq community edition broker from github using following link GitHub - hivemq/hivemq-community-edition: HiveMQ CE is a Java-based open source MQTT broker that fully supports MQTT 3.x and MQTT 5. It is the foundation of the HiveMQ Enterprise Connectivity and Messaging Platform
i cloned the project in intellij idea and build it then 21 test cases are failed
as per requirement i am using jdk11.
hivemq server starts on intellij and when i try to establish connection from mqtt-spy it shows not authorized (5) but when i downloaded their latest release and ran using cmd run.bat hivemq is starting gracefully and connection also established and i am able to use mqtt-spy to publish and subscribe.i want to use community edition broker so please help me.
i am new to hivemq, i have used mosquitto previously
TIA

Hello @sanket

Welcome to the HiveMQ Community! Please note that to use the HiveMQ Community Edition broker, you do not need to clone the repository and build it yourself. It is sufficient to download the release as a .zip file and start using it, as you have already done.

Is there any particular reason you want to build it? Have you tried using JDK 21?

Kind regards,
Diego from HiveMQ Team

the reason behind that is i am trying to replace rbac file extension with custom database so i want to know where exactly is starting point in hivemq broker after rbac-file-extension does its authentication. i checked many classes in hivemq broker but still not found where exactly it starts after authentication. so i want that point before connection so that i can use hardcoded value before connection and utilize it.

Hello @sanket

Please, focus the questions on the topic below instead of creating many new topics. Thank you!

Kind regards,
Diego from HiveMQ Team

hivemq community edition was working fine with rbac, then i removed rbac and created one client application and made its jar and placed it in the extension folder of hivemq broker and when i executed using run.bat command from cmd app got crashed. i reinstalled jdk still problem persist, and now i am trying to clone the hivemq broker again now its giving error sometimes related to deprecated features used in the project not comaptiable with gradle 9.0 but i noticed that broker is using gradle 8.5 on another machine it gives many errors in build.gradle.kts file and i am not able to build the broker and execute it through bin folder of distribution in broker with run.bat command.
TIA

Hi Sanket,

Thank you for reaching out. Could you please provide more details about your task? Specifically, are you looking to install the HiveMQ broker Community Edition with the File RBAC Extension, or are you developing your own extension for the HiveMQ Broker?

It would also be helpful to understand your background and the context of your project. Could you let us know which of the following best describes you and your project?

  • You are a student working on a student project.
  • You are a freelancer working on a project for a customer.
  • You are an engineer working on a project for your company. If so, which company?

This information will help us offer more targeted assistance. Looking forward to your response!

Best regards.
Dasha from the HiveMQ Team

i am trying to create extension where i want to know how to implement getAuthenticator() method of AuthenticatorProvider interface. i want to fetch username and password from connection request and provide it to isValidUser() method where it will try to authenticate credentials with database credentials.




below are the dependencies which i have used pom.xml

please help me out ASAP.
TIA

Hi @sanket,

It seems that you are following the “Extension Quick Start With Maven” guide from the HiveMQ Extension Developer Guide.

Could you please let me know at which step you are encountering an issue? Have you been able to successfully build the project so far?

To assist you further, I recommend watching this video tutorial, which provides a hands-on demonstration of how to build a HiveMQ extension using Maven.

We’re here to help, so please provide more details about the problem you’re facing, and we’ll work through it together.

Best regards.
Dasha from the HiveMQ Team

i have made extension as per video. i want to add my database where i have stored username and password. when i will try to connect through any client like mqtt-spy i want my method to fetch username and password from connection information and authenticate it with credentials stored in database. so what are the changes or steps to achieve this implementation.
TIA

i have created extension now, may i know where should my database file needs to be present in extension project so that after unzipping and deployment of extension in hivemq it will be accessible and work along. i deployed extension but it shows following error
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: User)
Authentication failed for user: Optional.empty
i have database named as User.db in the root directory of extension project and i reconfirmed that file do have User table and stored values of username and password. so what should i do now?
extension is also running
2024-06-27 12:23:03,695 INFO - This HiveMQ ID is Wzlqc
2024-06-27 12:23:10,920 INFO - Starting with file persistence mode.
2024-06-27 12:23:12,436 INFO - Starting HiveMQ extension system.
2024-06-27 12:23:12,821 INFO - Extension “Hello World Extension” version 0.0.1-SNAPSHOT started successfully.
2024-06-27 12:23:12,899 INFO - Starting TCP listener on address 0.0.0.0 and port 1883
2024-06-27 12:23:13,165 INFO - Started TCP Listener on address 0.0.0.0 and on port 1883.
2024-06-27 12:23:13,165 INFO - Started HiveMQ in 10263ms
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: User)

event file in log directory shows when i try to make connection
2024-06-27 13:05:22,136 - Client ID: NAMITAMATIA122426091, IP: 192.164.1.145 was disconnected. reason: Authentication failed, authenticator did not decide authenticity.
TIA

Hi Sanket,

Thank you for reaching out and providing the details about the issue you’re facing with your HiveMQ extension development. It sounds like you’re encountering difficulties with your SQLite database integration.

From the logs you’ve shared, the error message [SQLITE_ERROR] SQL error or missing database (no such table: User) indicates that the extension is unable to find the expected User table in your SQLite database (User.db).

It indicates that either your SQLite database (User.db) is not available or it does not contain table: User.

To troubleshoot this further:

  • Verify Database Contents: Double-check that the User.db file indeed contains the User table with the expected schema and data. Sometimes, discrepancies in table naming or schema can lead to such errors.
  • Database Connection Setup: Ensure that your extension code correctly points to the location of the User.db file.
  • Add logging: Add debug logging to your app about the status before and after establishing a connection to the SQL Lite DB.

Best regards,
Dasha from the HiveMQ Team

hello @Daria_H please look into this…
i have created extension which fetch username password and clientid from connection packet and authenticate with database and now i have created another table in the same database mentioning clientid as foreign key to implement ACL in that i have registered interceptors and it is working fine when i try to publish on the topic which is not having permission to publish by that particular client i have used preventPublishDelivery() method but there is no method where i can prevent the subscription because its working fine with publish but its not working for subscription… so is there any way to prevent subscription after checking permission from database? because my method is checking for topic if it is present and does it have permission but after checking it print log also but it cannot prevent subscription because there should be some method or way to prevent it like we can prevent publish wih preventPublishDelivery(). also please provide something for wildcard usage how to implement them ?
TIA

Hi Sanket
You do not have to implement preventPublishDelivery()

The Authenticator already onConnect can retrieve permissions that belong to the connecting client and add those to the AuthOutput. Then authorization should work.

Take a look at the File RBAC Extension as an example. In line 116 the Authenticator retrieves the permissions matching the clientId, username, and role:

These permissions will be used when the client publishes or subscribes.

Best,
Dasha from the HiveMQ Team

hello @Daria_H
i have created extension where authentication is done using database and topic permission and message limiting is also applied and it runs fine, but when i stop broker and again i try to start it then it crashes and shows A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ILLEGAL_INSTRUCTION (0xc000001d) at pc=0x00007ff908ca6c29, pid=9096, tid=7588

JRE version: Java™ SE Runtime Environment 18.9 (11.0.22+9) (build 11.0.22+9-LTS-219)

Java VM: Java HotSpot™ 64-Bit Server VM 18.9 (11.0.22+9-LTS-219, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)

Problematic frame:

C [librocksdbjni9375149578431949986.dll+0x546c29]

No core dump will be written. Minidumps are not enabled by default on client versions of Windows

An error report file with more information is saved as:

C:\Users\TAS\Downloads\hivemq-ce-2024.5\hivemq-ce-2024.5\bin\hs_err_pid9096.log

If you would like to submit a bug report, please visit:

Crash Report

The crash happened outside the Java Virtual Machine in native code.

See problematic frame for where to report the bug.

and if delete this broker and again use new one with my extension it works fine again. what is the issue that i am not able to run broker when i stop it ? in extension is there any cleanup process required when stopping broker? i am starting broker from hivemq-ce’s bin folder with run.bat command and when i need to stop it i press control + c to stop it. can you please give solution to get rid of this problem?
i have database inside bin directory of hivemq-ce and i fetched connection and closed it in extensionStop. please help me with solution which can avoid this problem
TIA

hello @Daria_H @Diego
i have created extension and i want to show all statistics like total connected clients, total subscriptions, total published message, total subscribed messages how can i do that? are there any inbuilt methods or some way to do this? i saw hivemq-dashboard likewise i want have all details.
TIA

Hi Sanket,

Thank you for reaching out!

To show all the statistics for your extension, such as total connected clients, total subscriptions, total published messages, and total subscribed messages, you can utilize HiveMQ’s built-in metrics. Here are the relevant metrics you can use:

  1. Total MQTT connections: com_hivemq_networking_connections_current
  2. Total subscriptions: com_hivemq_subscriptions_overall_current
  3. Total publish messages: com_hivemq_messages_incoming_publish_count, com_hivemq_messages_outgoing_publish_count
  4. Total subscribe messages: com_hivemq_messages_incoming_subscribe_count

For the metric list and detailed information, you can refer to the official HiveMQ broker metrics documentation here.

Additionally, to fetch these metric values within a HiveMQ broker extension, you can use the Metric Registry. Detailed documentation and an extension example on how to fetch a HiveMQ metric are available here.

I hope this helps! If you have any more questions or need further assistance, please feel free to ask.

Best regards,
Dasha from the HiveMQ Team

hello @Diego @Daria_H
i have implemented as you said above but i have some confusion. Total publish messages: com_hivemq_messages_incoming_publish_count, com_hivemq_messages_outgoing_publish_count
Total subscribe messages: com_hivemq_messages_incoming_subscribe_count can you please explain above three terms in details or provide some documentation where i can understand metrics terms because when i publish message from mqtt-spy that time com_hivemq_messages_incoming_publish_count metric increased then i suscribed in mqtt-spy then com_hivemq_messages_outgoing_publish_count increased but com_hivemq_messages_incoming_subscribe_count metric is still null. so i want to know details about above metrics and if possible i want to know many metrics that are frequently used. like unauthorized user metrics and so on
TIA

Hi Sanket,

Thank you for reaching out and providing the details of your confusion.

I apologize for any confusion caused by the metrics. The subscribe metric, specifically com_hivemq_messages_incoming_subscribe_count, is not available in the Community Edition of the HiveMQ broker. This metric is only accessible in the HiveMQ broker Enterprise Edition.

Currently, the Community Edition offers a set of straightforward metrics which include:

  • com.hivemq.messages.incoming.total.count
  • com.hivemq.messages.outgoing.total.count
  • com.hivemq.messages.incoming.connect.count
  • com.hivemq.messages.incoming.publish.count
  • com.hivemq.messages.outgoing.publish.count
  • com.hivemq.messages.dropped.count
  • com.hivemq.messages.retained.current
  • com.hivemq.networking.bytes.read.total
  • com.hivemq.networking.bytes.write.total
  • com.hivemq.networking.connections.current
  • com.hivemq.networking.connections-closed.total.count
  • com.hivemq.subscriptions.overall.current
  • com.hivemq.sessions.overall.current

Unfortunately, this means that you won’t be able to track subscribe messages using the Community Edition.

If you need more detailed metrics, including those for unauthorized users and other advanced features, you might want to consider the Enterprise Edition.

I hope this clears up the confusion. Please let us know if you have any more questions or need further assistance.

Best,
Dasha from the HiveMQ Team

hello, @Daria_H @Diego
can i use two extension at a time in single broker? i have custom extension and now i want to use hivemq-heartbeat-extension so what should i do? can i get detail information regarding hivemq-heartbeat-extension.
TIA

Hi @sanket

Yes, you can use multiple extensions simultaneously with a single broker, including your custom extension and the HiveMQ Heartbeat Extension.

For detailed information about the HiveMQ Heartbeat Extension, including installation instructions, please refer to the following link: GitHub - hivemq/hivemq-heartbeat-extension: HiveMQ extension for integration with load balancers and proxies

If you have any further questions or need additional assistance, feel free to reach out. We’re here to help!

Best regards,
Dasha from the HiveMQ Team