public interface MqttServer
You can accept incoming MQTT connection requests providing a endpointHandler(Handler). As the
requests arrive, the handler will be called with an instance of MqttEndpoint in order to manage the
communication with the remote MQTT client.
| Modifier and Type | Method and Description |
|---|---|
int |
actualPort()
The actual port the server is listening on.
|
Future<Void> |
close()
Close the server.
|
void |
close(Handler<AsyncResult<Void>> completionHandler)
Close the server supplying an handler that will be called when the server is actually closed (or has failed).
|
static MqttServer |
create(Vertx vertx)
Return an MQTT server instance using default options
|
static MqttServer |
create(Vertx vertx,
MqttServerOptions options)
Return an MQTT server instance
|
MqttServer |
endpointHandler(Handler<MqttEndpoint> handler)
Set the endpoint handler for the server.
|
MqttServer |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler for the server, that will be called when an error happens independantly of an
accepted
MqttEndpoint, like a rejected connection |
Future<MqttServer> |
listen()
Start the server listening for incoming connections using the specified options
through the constructor
|
MqttServer |
listen(Handler<AsyncResult<MqttServer>> listenHandler)
Start the server listening for incoming connections using the specified options
through the constructor
|
Future<MqttServer> |
listen(int port)
Start the server listening for incoming connections on the port specified but on
"0.0.0.0" as host.
|
MqttServer |
listen(int port,
Handler<AsyncResult<MqttServer>> listenHandler)
Start the server listening for incoming connections on the port specified but on
"0.0.0.0" as host.
|
Future<MqttServer> |
listen(int port,
String host)
Start the server listening for incoming connections on the port and host specified
|
MqttServer |
listen(int port,
String host,
Handler<AsyncResult<MqttServer>> listenHandler)
Start the server listening for incoming connections on the port and host specified
It ignores any options specified through the constructor
|
default Future<Boolean> |
updateSSLOptions(SSLOptions options)
Update the server with new SSL
options, the update happens if the options object is valid and different
from the existing options object. |
Future<Boolean> |
updateSSLOptions(SSLOptions options,
boolean force)
Update the server with new SSL
options, the update happens if the options object is valid and different
from the existing options object. |
default void |
updateSSLOptions(SSLOptions options,
boolean force,
Handler<AsyncResult<Boolean>> handler)
Like
updateSSLOptions(SSLOptions, boolean) but supplying a handler that will be called when the update
happened or has failed. |
default void |
updateSSLOptions(SSLOptions options,
Handler<AsyncResult<Boolean>> handler)
Like
updateSSLOptions(SSLOptions) but supplying a handler that will be called when the update
happened or has failed. |
static MqttServer create(Vertx vertx, MqttServerOptions options)
vertx - Vert.x instanceoptions - MQTT server optionsstatic MqttServer create(Vertx vertx)
vertx - Vert.x instanceFuture<MqttServer> listen()
Future completed with this server instanceFuture<MqttServer> listen(int port, String host)
port - the port to listen onhost - the host to listen onFuture completed with this server instanceMqttServer listen(int port, String host, Handler<AsyncResult<MqttServer>> listenHandler)
port - the port to listen onhost - the host to listen onlistenHandler - handler called when the asynchronous listen call endsFuture<MqttServer> listen(int port)
port - the port to listen onFuture completed with this server instanceMqttServer listen(int port, Handler<AsyncResult<MqttServer>> listenHandler)
port - the port to listen onlistenHandler - handler called when the asynchronous listen call endsMqttServer listen(Handler<AsyncResult<MqttServer>> listenHandler)
listenHandler - handler called when the asynchronous listen call endsMqttServer endpointHandler(Handler<MqttEndpoint> handler)
handler - the endpoint handlerMqttServer exceptionHandler(Handler<Throwable> handler)
MqttEndpoint, like a rejected connectionhandler - the exception handlerdefault Future<Boolean> updateSSLOptions(SSLOptions options)
options, the update happens if the options object is valid and different
from the existing options object.
This is equivalent to calling updateSSLOptions(SSLOptions, boolean) with force set to
false.
The boolean succeeded future result indicates whether the update occurred.
options - the new SSL optionsdefault void updateSSLOptions(SSLOptions options, Handler<AsyncResult<Boolean>> handler)
updateSSLOptions(SSLOptions) but supplying a handler that will be called when the update
happened or has failed.options - the new SSL optionshandler - the update handlerFuture<Boolean> updateSSLOptions(SSLOptions options, boolean force)
options, the update happens if the options object is valid and different
from the existing options object.
The options object is compared using its equals method against the existing options to prevent
an update when the objects are equal since loading options can be costly. When options are equal, setting
force to true forces the update.
The boolean succeeded future result indicates whether the update occurred.
options - the new SSL optionsforce - force the update when options are equaldefault void updateSSLOptions(SSLOptions options, boolean force, Handler<AsyncResult<Boolean>> handler)
updateSSLOptions(SSLOptions, boolean) but supplying a handler that will be called when the update
happened or has failed.options - the new SSL optionsforce - force the update when options are equalhandler - the update handlerint actualPort()
Future<Void> close()
The close happens asynchronously and the server may not be closed until some time after the call has returned.
Future completed with this server is closedvoid close(Handler<AsyncResult<Void>> completionHandler)
completionHandler - the handler called on completionCopyright © 2026 Eclipse. All rights reserved.