B4J Question MqttBroker problem

uniplan

Active Member
Licensed User
Longtime User
I have realized a MQTT brokers using the MQTT library.
I used the following code:

B4X:
broker.Initialize("", 51042)            
broker.SetUserAndPassword("xxxxx","yyyyyy")

and

B4X:
broker.Start

The broker works properly.

The problems have arisen when I tried to move the broker to another server.

On the new server, when I run:

B4X:
broker.Start

I have this error:

Waiting for debugger to connect...
Program started.
Persistent store file: G:\MODULI~1\B4J\varie\B4JBRO~1\Objects\moquette_store.mapdb
Starting without ACL definition
Server binded host: 0.0.0.0, port: 51043
Server binded host: 0.0.0.0, port: 8080
Error occurred on line: 42
java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:125)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:478)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1021)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:455)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:440)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:844)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:197)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:350)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
at java.lang.Thread.run(Thread.java:745)
Server stopping...
onEvent processing messaging event from input ringbuffer org.eclipse.moquette.spi.impl.events.StopEvent@13df9061
Msg read: 0, msg wrote: 0
Bytes read: 0, bytes wrote: 0
Server stopped

I checked and the port is not in use.

I have also tried it on other servers. Some work and some do not.

What could be the problem?
 
Top