Closed iwas108 closed 3 years ago
Can you try removing/commenting out the below line from your thingsboard.conf
?
export MQTT_BIND_PORT=8883
This will start the server. But I am not sure if your secure MQTT will work after this change. But I can see that even without the above configuration, the thingsboard process is getting attached to the ports 1883 and 8883, so you can give it a try.
I am facing a similar issue in Thingsboard 3.3 This was on a fresh instance of thingsboard, all was fine until I tried to install a self-signed certificate to secure the MQTT connection by following the steps available here
Stack trace:
ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MqttTransportService': Invocation of init method failed; nested exception is java.net.BindException: Address already in use
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:415)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1791)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:755)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:402)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236)
at org.thingsboard.server.ThingsboardServerApplication.main(ThingsboardServerApplication.java:38)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467)
Caused by: java.net.BindException: Address already in use
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:455)
at java.base/sun.nio.ch.Net.bind(Net.java:447)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:134)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:506)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:491)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:260)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
I had configured to use the port number 8883
as suggested in the documentation.
I can also verify that there is no process listening to that port before starting the thignsboard service
But after the above error log, I can see the process created by Thingsboard still attached to that port
$ lsof -i :8883
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 12046. thingsboard 65u IPv6 65043 0t0 TCP *:8883 (LISTEN)
Then only I figured out that thingboard is attaching to the ports 1883
and 8883
by default without any external configuration.
Hint : v3.3 Release notes
Ability to launch MQTT and MQTTS simultaneously in one transport instance
It looks like the same process tried to attach the port again which resulted in the server crashing, but strangely if the MQTT_BIND_PORT
is set to 1883
there is no problem in server startup.
FYI : I am still struggling to set up a secure MQTT
Commenting out,
export MQTT_BIND_PORT=8883
Fixed the problem, thingsboard service started successfuly with SSL enabled.
Closing this issue, thankyou verymuch!
Thanks @iwas108, it was the solution. But later I found the instruction in the upgrade guide:
export MQTT_SSL_ENABLED=true
export MQTT_SSL_BIND_ADDRESS=0.0.0.0
export MQTT_SSL_BIND_PORT=8883
export MQTT_BIND_ADDRESS=0.0.0.0
export MQTT_BIND_PORT=1883
So change from MQTT_BIND_PORT=8883
to MQTT_SSL_BIND_PORT=8883
is necessary at upgrading to 3.3.x
Describe the bug Upgrade from 3.2.2 to 3.3 on Ubuntu Server 12.04 resulting in failed to start thingsboard service.
Your Server Environment
Your Client Environment
Desktop (please complete the following information):
Your Device
Connectivity
Device vendor and model
To Reproduce Steps to reproduce the behavior:
Expected behavior After executing final step of sudo service thingsboard start it should start the thingsboard service version 3.3, but it failed with error.
Screenshots
Additional context Here is my thingsboard.conf